1.准备工作
安装CENTOS7.3后我们将从软件集合(SCL)信息库安装Python 3.6软件包。
通过启用SCL,您将可以访问核心存储库中不提供的较新版本的编程语言和服务。使用以下命令启用EPEL和SCL存储库:
- [root@localhost ~]# yum install epel-release centos-release-scl
启用存储库后,安装Python 3.6以构建Odoo依赖项所需的所有工具:
- [root@localhost ~]# yum install rh-python36 git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel
在安装过程中,系统将提示您接受GPG密钥。
2.创建Odoo用户
- [root@localhost ~]# useradd -m -U -r -d /opt/odoo12 -s /bin/bash odoo12
- [root@localhost ~]#
3.安装和配置PostgreSQL
这里必须安装postgres10以上数据库,我们将从官方PostgreSQL存储库安装PostgreSQL 10。
首先启用PostgreSQL存储库:
- [root@localhost /]# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
已加载插件:fastestmirror, langpacks安装PostgreSQL服务器并创建一个新的PostgreSQL数据库集群:
- [root@localhost /]# yum install postgresql10-server postgresql10-devel
- 初始化数据库
- [root@localhost /]# /usr/pgsql-10/bin/postgresql-10-setup initdb
- Initializing database ... OK
- [root@localhost /]#
安装完成后,启用并启动PostgreSQL服务:
- [root@localhost /]# systemctl enable postgresql-10
- Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-10.service to /usr/lib/systemd/system/postgresql-10.service.
- [root@localhost /]# systemctl start postgresql-10
- [root@localhost /]#
在本例中,创建一个与先前创建的系统用户同名的PostgreSQL用户odoo12:
- [root@localhost /]# su - postgres -c "createuser -s odoo12"
- [root@localhost /]#
4.安装Wkhtmltopdf
该wkhtmltox软件包提供了一组开源命令行工具,可以将HTML渲染为PDF和各种图像格式。为了打印PDF报告,您将需要该wkhtmltopdf工具。Odoo的推荐版本0.12.1在官方CentOS 7存储库中不可用。使用以下wget命令下载推荐的版本:
- [root@localhost ~]# wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
- --2019-12-14 13:51:14-- https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.1/wkhtmltox-0.12.1_linux-centos7-amd64.rpm
- 正在解析主机 github.com (github.com)... 13.250.177.223
- 正在连接 github.com (github.com)|13.250.177.223|:443... 已连接。
下载完成后,rpm输入以下命令安装软件包:
- [root@localhost ~]# yum localinstall wkhtmltox-0.12.1_linux-centos7-amd64.rpm
5.安装和配置Odoo 12
在开始安装过程之前,请确保切换到用户 “ odoo12”:
- [root@localhost ~]# sudo su - odoo12
- [odoo12@localhost ~]$
首先从Odoo GitHub存储库克隆Odoo 12源代码:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo12/odoo
由于这里下载慢的问题,从本地直接上传
启用软件集合,以便我们可以访问python 3.6二进制文件:
- [odoo12@localhost ~]$ scl enable rh-python36 bash
- [odoo12@localhost ~]$
使用以下命令为Odoo安装创建一个新的Python虚拟环境:
- [odoo12@localhost ~]$ cd /opt/odoo12
- [odoo12@localhost ~]$ python3 -m venv venv
- [odoo12@localhost ~]$
激活环境:
- [odoo12@localhost ~]$ source venv/bin/activate
- (venv) [odoo12@localhost ~]$
安装所有必需的Python模块:
- (venv) [odoo12@localhost ~]$ pip install -r requirements.txt
安装完成后,请使用以下命令停用环境:
- (venv) [odoo12@localhost ~]$deactivate
为自定义插件创建一个新目录:
- [root@localhost /]# mkdir /opt/odoo12/mycustom-addons
切回sudo用户eixt
复制文件,
- [root@localhost /]# cp /opt/odoo12/odoo/debian/odoo.conf /etc/odoo12.conf
接下来,打开文本编辑器并创建以下配置文件:
- [root@localhost /]# vi /etc/odoo12.conf
- [options]
- ; This is the password that allows database operations:
- admin_passwd = my_admin_passwd
- db_host = False
- db_port = False
- db_user = odoo12
- db_password = False
- addons_path = /opt/odoo12/odoo/addons,/opt/odoo12/mycustom-addons
保存并关闭文件。
6.创建一个系统单位文件
要将Odoo作为服务运行,我们将创建一个单位文件。
打开您的文本编辑器,并odoo12.service在/etc/systemd/system/目录内创建一个文件:
- [root@localhost /]# vi /etc/systemd/system/odoo12.service
- [root@localhost /]#
- ==========================
- [Unit]
- Description=Odoo12
- Requires=postgresql-10.service
- After=network.target postgresql-10.service
- [Service]
- Type=simple
- SyslogIdentifier=odoo12
- PermissionsStartOnly=true
- User=odoo12
- Group=odoo12
- ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo/odoo-bin -c /etc/odoo12.conf
- StandardOutput=journal console
- [Install]
- WantedBy=multi-user.target
- =================================
通知Systemd我们创建了一个新的单位文件:
- [root@localhost /]# systemctl daemon-reload
- [root@localhost /]#
通过执行以下命令来启动并启用Odoo服务:
- [root@localhost /]# systemctl enable odoo12
- Created symlink from /etc/systemd/system/multi-user.target.wants/odoo12.service to /etc/systemd/system/odoo12.service.
- [root@localhost /]# systemctl start odoo12
使用以下命令检查服务状态:
- [root@localhost /]# systemctl status odoo12
- ● odoo12.service - Odoo12
- Loaded: loaded (/etc/systemd/system/odoo12.service; enabled; vendor preset: disabled)
- Active: active (running) since 六 2019-12-14 15:57:46 CST; 7s ago
- Main PID: 19430 (scl)
- Tasks: 6
- CGroup: /system.slice/odoo12.service
- ├─19430 /usr/bin/scl enable rh-python36 -- /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo-bin -c /etc/odoo12.conf
- ├─19431 /bin/bash /var/tmp/sclIKnSZo
- └─19434 /opt/odoo12/venv/bin/python3 /opt/odoo12/odoo-bin -c /etc/odoo12.conf
- 12月 14 15:57:46 localhost.localdomain systemd[1]: Started Odoo12.
- 12月 14 15:57:47 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:47,638 19434 INFO ? odoo: Odoo version 12.0 e-20190726
- 12月 14 15:57:47 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:47,638 19434 INFO ? odoo: Using configuration file at /etc/odoo12.conf
- 12月 14 15:57:47 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:47,638 19434 INFO ? odoo: addons paths: ['/opt/odoo12/.local/share/Odoo/addons/12.0', '/opt/odoo12/odoo/add...om-addons']
- 12月 14 15:57:47 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:47,638 19434 INFO ? odoo: database: odoo12@default:default
- 12月 14 15:57:47 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:47,946 19434 INFO ? odoo.addons.base.models.ir_actions_report: You need Wkhtmltopdf to print a pdf version ...he reports.
- 12月 14 15:57:48 localhost.localdomain odoo12[19430]: 2019-12-14 07:57:48,251 19434 INFO ? odoo.service.server: HTTP service (werkzeug) running on localhost.localdomain:8069
- Hint: Some lines were ellipsized, use -l to show in full.
- [root@localhost /]#
7.测试
http://10.128.25.135:8069/
关闭防火墙或者开放8069端口。
- [root@localhost /]# systemctl stop firewalld
- [root@localhost /]# systemctl start firewalld
- [root@localhost /]# firewall-cmd --permanent --zone=public --add-port=8069/tcp
- success
- [root@localhost /]# firewall-cmd --reload
- success
- [root@localhost /]#