安装Odoo13

更新包:

yum -y upgrade

安装Python3.8:(Python版本>=3.6)

yum install python38

链接Python3到Python3.8:(非必须,可以直接使用python3.8命令)

mv /usr/bin/python3 /usr/bin/python3.bak
ln -s /usr/bin/python3.8 /usr/bin/python3

安装宝塔:(用于做反向代理,提供外网访问。)

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

下载和上传:https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.centos8.x86_64.rpm
然后安装Wkhtmltopdf:(用于Odoo打印导出pdf)

yum install -y wkhtmltox-0.12.6-1.centos8.x86_64.rpm

安装依赖包:(否则执行pip install -r requirements.txt命令会出错)

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel

yum install python3-pip python3-wheel python3-setuptools python3-devel postgresql-devel cyrus-sasl-devel.x86_64 openldap openldap-devel

创建目录:(用于存放python虚拟环境、odoo的程序和配置文件)

mkdir /www/odoo/server
mkdir /www/odoo/venv

https://www.odoo.com/zh_CN/page/download下载Odoo 14 Community版本的Sources文件,解压根目录下的文件至/www/odoo/server目录。

创建虚拟环境:(独立运行的Python环境)

python3.8 -m venv /www/odoo/venv

进人Python虚拟目录。

激活环境:

source /www/odoo/venv/bin/activate

更新pip:

pip install --upgrade pip

安装Odoo依赖包:

pip install -r /www/odoo/server/requirements.txt

安装Odoo:

python3 /www/odoo/server/setup.py install

(安装后的目录:)

/www/odoo/venv/lib64/python3.8/site-packages/odoo-14.0.post20201226-py3.8.egg/odoo/

退出Python虚拟目录。
删除/www/odoo/server/目录。(安装后该目录就没有用了。)

安装PostgreSQL数据库:

# Install the repository RPM:
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

# Disable the built-in PostgreSQL module:
sudo dnf -qy module disable postgresql

# Install PostgreSQL:
sudo dnf install -y postgresql13-server

# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13

修改数据库密码:(postgres和odoo)

sudo su - postgres -c "createuser -s odoo"
sudo -u postgres psql
ALTER USER postgres WITH PASSWORD '密码1';
ALTER USER odoo WITH PASSWORD '密码2';

创建目录:(扩展模块目录和会话数据目录)

mkdir /www/odoo/my-addons
mkdir /www/odoo/odoo-data

创建odoo.conf配置文件内容:

[options]
admin_passwd = Odoo的管理密码
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo账号的数据库密码
addons_path = /www/odoo/venv/lib/python3.8/site-packages/odoo-14.0.post20201226-py3.8.egg/odoo/addons,/www/odoo/my-addons
data_dir = /www/odoo/odoo-data
logfile = /www/odoo/odoo-server.log
wokers=3
http_port = 8069

创建系统用户:(用于独立运行odoo,否则会提示root问题)

sudo adduser odoo

修改目录拥有者为odoo:

chown -R odoo /www/odoo

使用用户:

sudo su - odoo

进入虚拟环境:

source /www/odoo/venv/bin/activate

启动Odoo:

odoo -c /www/odoo/odoo.conf

安装pgAdmin4

安装依赖包:

yum install -y gdbm-devel python3-devel libffi-devel openssl openssl-devel make automake gcc gcc-c++ kernel-devel glib2-devel libxslt-devel zlib-devel

yum install -y libxml2 libxml2-devel --nobest

进入环境

source /www/odoo/venv/bin/activate

下载和上传:
https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v4.23/pip/pgadmin4-4.23-py3-none-any.whl

安装

pip3 install /www/odoo/pgadmin4-4.23-py3-none-any.whl

安装后目录:/www/odoo/venv/bin/pgadmin4

启动:
pgadmin4

添加Odoo开机启动

nano /usr/lib/systemd/system/odoo.service

内容如下:

[Unit]
Description=Odoo
Requires=postgresql-13.service
After=network.target postgresql-13.service


[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/www/odoo/venv/bin/python3 /www/odoo/venv/bin/odoo -c /www/odoo/odoo.conf
StandardOutput=journal+console


[Install]
WantedBy=multi-user.target

启用:

systemctl daemon-reload
systemctl enable --now odoo

其他命令:
查看服务状态:
systemctl status odoo
重启服务:
systemctl restart odoo
停止服务:
systemctl stop odoo
启动服务:
systemctl start odoo
查看服务日志:
journalctl -u odoo

添加pgAdmin4开机启动

添加目录:

mkdir /var/lib/pgadmin
mkdir /var/log/pgadmin
chown -R odoo /var/lib/pgadmin
chown -R odoo /var/log/pgadmin

添加启动:
nano /usr/lib/systemd/system/pgadmin4.service
内容如下:

[Unit]
Description=pgadmin4


[Service]
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/www/odoo/venv/bin/python3 /www/odoo/venv/bin/pgadmin4
StandardOutput=journal+console


[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now pgadmin4

其他命令:
查看服务状态:
systemctl status pgadmin4
重启服务:
systemctl restart pgadmin4
停止服务:
systemctl stop pgadmin4
启动服务:
systemctl start pgadmin4
查看服务日志:
journalctl -u pgadmin4