CentOS 7快速安装配置 Odoo 12

CentOS 7快速安装配置 Odoo 12

 Coding  Alan  9个月前 (10-19)  3703次浏览  3个评论

CentOS 7快速安装配置 Odoo 12

Odoo 12已正式发布,在 Github 和Nigthly 均可下载源码,此前在博客上发布了Ubuntu 快速安装配置Odoo 12,本文探讨 CentOS 上安装 Odoo 12的相关内容。

最好用的免费ERP系统Odoo 12开发手册新鲜出炉,已完结

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

sudo yum -y update

sudo yum -y install epel-release

# 添加Software Collections (SCL) 安装 Python

sudo yum -y install centos-release-scl

sudo yum -y install rh-python36

# 或直接执行(可能需要提前执行yum -y groupinstall "Development tools")

sudo yum -y install python36 python36-devel

# 又或者

curl -O https://www.python.org/ftp/python/3.6.7/Python-3.6.7rc2.tgz

tar xf Python-3.6.7rc2.tgz

cd Python-3.6.7rc2

./configure

make

sudo make install

# 安装其它所需依赖

sudo yum -y install git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel

补充:更新国内 yum 源

1

2

3

4

sudo yum install wget -y

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak

sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

sudo yum makecache

源码安装 Python 3.7

1

2

3

4

5

6

7

8

9

10

11

12

13

cd /tmp

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz

tar xzf Python-3.7.2.tgz

cd Python-3.7.2/

./configure --enable-optimizations

make altinstall

# 重新设置 python3的软链接

rm -f /usr/bin/python3

ln -s /usr/local/bin/python3.7 /usr/bin/python3

# 解决如下报错:yum install libffi-devel -y

ModuleNotFoundError: No module named '_ctypes'

make: *** [altinstall] Error 1

注:当前不太建议使用 Python 3.7,可能存在兼容问题

添加新用户(可选)

1

sudo useradd -m -U -r -d /opt/odoo -s /bin/bash odoo

安装和配置 PostgreSQL

1

2

3

4

5

6

7

8

9

10

sudo yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

sudo yum install postgresql10 postgresql10-server -y

# 初始化

sudo /usr/pgsql-10/bin/postgresql-10-setup initdb

# 启动服务

sudo systemctl enable postgresql-10

sudo systemctl start postgresql-10

# 创建用户(可任选名称,与前面创建的系统用户名需相同)

sudo su - postgres -c "createuser -s odoo"

注意:Odoo 12要求安装 PostgreSQL 10否则会出现报错:

1

Database creation error: relation "ir_model" does not exist LINE 1: SELECT * FROM ir_model WHERE state='manual'

安装Wkhtmltopdf

1

2

3

4

wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm

sudo yum localinstall wkhtmltox-0.12.5-1.centos7.x86_64.rpm -y

# 中文字体

sudo yum install -y wqy*

安装Sass

1

2

<span class="hljs-comment">sudo yum install -y sassc</span>

安装 Odoo

用户准备

不设置执行后述操作时会报出xxx is not in the sudoers file. This incident will be reported.

1

2

3

4

su - root

visudo

# 在root    ALL=(ALL)       ALL下添加相应用户

odoo    ALL=(ALL)       ALL

安装及配置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

# 切换用户

sudo su - odoo

cd /opt/odoo

wget http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz

# 或git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo12

tar -zxvf odoo_12.0.latest.tar.gz

mv odoo-12.0.post20181019/ odoo12

# 当前使用 nightly 版本有一个坑,需要自行添加 odoo-bin 文件

#!/usr/bin/env python3

# set server timezone in UTC before time module imported

__import__('os').environ['TZ'] = 'UTC'

import odoo

if __name__ == "__main__":

    odoo.cli.main()

#添加执行权限

chmod +x odoo12/odoo-bin

#环境搭建

python36 -m venv odoo12-venv

source odoo12-venv/bin/activate

# 或者 Virtualenvwrapper(使用这种方法/etc/systemd/system/odoo12.service也需调整)

curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"

python36 get-pip.py

pip3 install virtualenvwrapper

# vi ~/.bashrc

export WORKON_HOME=/opt/virtualenvs

# export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python36

source /usr/bin/virtualenvwrapper.sh

#重载.bashrc

source  ~/.bashrc

# 安装依赖包

pip3 install -i https://pypi.douban.com/simple -r odoo12/requirements.txt

deactivate

# 创建自定义插件目录,如果使用 Git 建议将 local-addons 放在与 odoo12同一级

mkdir odoo12/local-addons

# 创建配置文件(<a href="https://www.jianshu.com/p/abf366d7319e" target="_blank" rel="noopener" data-mce-href="https://www.jianshu.com/p/abf366d7319e">配置项详解参考</a>)

# odoo12/odoo-bin --help也可进行查看

sudo vi /etc/odoo12.conf

[options]

; This is the password that allows database operations:

# 此处密码请自行修改

admin_passwd = superadmin_passwd

db_host = False

db_port = False

db_user = odoo

db_password = False

; addons_path = /opt/odoo/odoo12/odoo/addons

; If you are using custom modules

addons_path = /opt/odoo/odoo12/odoo/addons,/opt/odoo/odoo12/local-addons

添加服务

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

sudo vi /etc/systemd/system/odoo12.service

[Unit]

Description=Odoo12

Requires=postgresql-10.service

After=network.target postgresql-10.service

[Service]

Type=simple

SyslogIdentifier=odoo12

PermissionsStartOnly=true

User=odoo

Group=odoo

WorkingDirectory=/opt/odoo

Environment=/opt/odoo/odoo12-venv/bin/activate

ExecStart=/opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf

# ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo12.conf

StandardOutput=journal+console

[Install]

WantedBy=multi-user.target

# 启动服务

sudo systemctl daemon-reload

sudo systemctl start odoo12

示例配置文件

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

[options]

addons_path = /usr/lib/python3/dist-packages/odoo/addons

admin_passwd = $pbkdf2-sha512$25000$y9k7Z4zROifEOOf8v5fSeg$WD0vlcapmdkyCY8Uy9Md/Z1kchm8Sj942E4B1Ry13iwcCKaRFf1t3DEPYQrsB6iPwb2K/kJ6obs9CX2HRsx9KA

csv_internal_sep = ,

data_dir = /var/lib/odoo/.local/share/Odoo

db_host = False

db_maxconn = 64

db_name = False

db_password = False

db_port = False

db_sslmode = prefer

db_template = template0

db_user = odoo

dbfilter =

demo = {}

email_from = False

geoip_database = /usr/share/GeoIP/GeoLite2-City.mmdb

http_enable = True

http_interface =

http_port = 8069

import_partial =

limit_memory_hard = 2684354560

limit_memory_soft = 2147483648

limit_request = 8192

limit_time_cpu = 60

limit_time_real = 120

limit_time_real_cron = -1

list_db = True

log_db = False

log_db_level = warning

log_handler = :INFO

log_level = info

logfile = /var/log/odoo/odoo-server.log

logrotate = False

longpolling_port = 8072

max_cron_threads = 2

osv_memory_age_limit = 1.0

osv_memory_count_limit = False

pg_path = None

pidfile = None

proxy_mode = False

reportgz = False

server_wide_modules = base,web

smtp_password = False

smtp_port = 25

smtp_server = localhost

smtp_ssl = False

smtp_user = False

syslog = False

test_enable = False

test_file = False

test_tags = None

translate_modules = ['all']

unaccent = False

without_demo = False

workers = 0

发布了73 篇原创文章 · 获赞 41 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/weixin_37989267/article/details/96994532

相关文章