【原创】源码安装多版本odoo(含odoo12.0、13.0、14.0、15.0、16.0、17.0、18.0)
【原创】源码安装多版本odoo(含odoo12.0、13.0、14.0、15.0、16.0、17.0、18.0)
思路:
前提基于ubuntu22,并且预先配好中国大陆ubuntu安装源:
参考:https://linuxmirrors.cn/use/
一、在ubunt安装好odoo的运行环境依赖:
sudo apt-get update
sudo apt-get install -y python3-pip
sudo apt install git python3-pip build-essential wget python3-dev python3-venv \
python3-wheel libfreetype6-dev libxml2-dev libzip-dev libldap2-dev libsasl2-dev \
python3-setuptools node-less libjpeg-dev zlib1g-dev libpq-dev \
libxslt1-dev libldap2-dev libtiff5-dev libjpeg8-dev libopenjp2-7-dev \
liblcms2-dev libwebp-dev libharfbuzz-dev libfribidi-dev libxcb1-dev
二、Python 依赖安装好之后,还需要安装一些前端所需的npm依赖包:
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
这里如果npm依赖包的安装很慢,请更换淘宝最新的npm源:设置命令如下:
sudo npm config set registry https://registry.npmmirror.com
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less
三、安装PostgreSQL数据库:用UBUNTU自带的DEB包直接安装的:
sudo apt-get install postgresql
安装完使用以下命令把PG数据库启动:
sudo systemctl start postgresql
查看一下状态:
sudo systemctl status postgresql
设置PG数据库开机自动启动:
sudo systemctl enable postgresql
试这条命令登陆进pgsql:
sudo -u postgres psql
分别给odoo12.0、13.0、14.0、15.0、16.0、17.0、18.0各版本单独创建账户:
创建数据库用户:
sudo su - postgres -c "createuser -s odoo12"
sudo su - postgres -c "createuser -s odoo13"
sudo su - postgres -c "createuser -s odoo14"
sudo su - postgres -c "createuser -s odoo15"
sudo su - postgres -c "createuser -s odoo16"
sudo su - postgres -c "createuser -s odoo17"
sudo su - postgres -c "createuser -s odoo18"
sudo -u postgres psql
ALTER USER odoo12 WITH SUPERUSER;
ALTER USER odoo13 WITH SUPERUSER;
ALTER USER odoo14 WITH SUPERUSER;
ALTER USER odoo15 WITH SUPERUSER;
ALTER USER odoo16 WITH SUPERUSER;
ALTER USER odoo17 WITH SUPERUSER;
ALTER USER odoo18 WITH SUPERUSER;
\q
exit
四、创建odoo专用的ubuntu账号,用于运行odoo
-r创建一个系统用户,-m自动创建用户的主目录,-d /opt/odoo指定用户的主目录路径为/opt/odoo,-s /bin/bash指定用户的登陆shell为bash,最末尾的odoo15是要创建的用户名:
sudo useradd -r -m -d /opt/odoo -s /bin/bash odoo15
sudo usermod -aG odoo odoo15
为创建的用户帐户设置密码
sudo passwd odoo12
sudo passwd odoo13
sudo passwd odoo14
sudo passwd odoo15
sudo passwd odoo16
sudo passwd odoo17
sudo passwd odoo18
五、使用python venv环境来运行各版本odoo,当某个版本的Odoo要使用其它python包时不冲突。
sudo su - odoo12
cd /opt/odoo/
python3 -m venv odoo12-venv
source odoo12-venv/bin/activate
sudo su - odoo13
cd /opt/odoo/
python3 -m venv odoo13-venv
source odoo13-venv/bin/activate
sudo su - odoo14
cd /opt/odoo/
python3 -m venv odoo14-venv
source odoo14-venv/bin/activate
sudo su - odoo15
cd /opt/odoo/
python3 -m venv odoo15-venv
source odoo15-venv/bin/activate
sudo su - odoo16
cd /opt/odoo/
python3 -m venv odoo16-venv
source odoo16-venv/bin/activate
sudo su - odoo17
cd /opt/odoo/
python3 -m venv odoo17-venv
source odoo17-venv/bin/activate
sudo su - odoo18
cd /opt/odoo/
python3 -m venv odoo18-venv
source odoo18-venv/bin/activate
这里pip的install速度太慢了,先切到清华源(阿里的源好像有点问题):
先把pip3切换到清华源/阿里源:
mkdir ~/.pip
vi ~/.pip/pip.conf
然后将下面这两行复制进去就好了
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
再运行下边命令,速度就很快了:
python -m pip install --upgrade pip
接着安装odoo源码带的requirements.txt依赖运行环境:
pip install wheel
pip install --upgrade pip
pip install setuptools --upgrade
pip3 install -r /opt/odoo/odoo12-source/requirements.txt
pip3 install -r /opt/odoo/odoo13-source/requirements.txt
pip3 install -r /opt/odoo/odoo14-source/requirements.txt
pip3 install -r /opt/odoo/odoo15-source/requirements.txt
pip3 install -r /opt/odoo/odoo16-source/requirements.txt
pip3 install -r /opt/odoo/odoo17-source/requirements.txt
pip3 install -r /opt/odoo/odoo18-source/requirements.txt
成功安装后,停用python venv虚拟环境,
$deactivate
$exit
创建Odoo各版本的日志文件:
sudo touch /var/log/odoo/odoo12.log
sudo touch /var/log/odoo/odoo13.log
sudo touch /var/log/odoo/odoo14.log
sudo touch /var/log/odoo/odoo15.log
sudo touch /var/log/odoo/odoo16.log
sudo touch /var/log/odoo/odoo17.log
sudo touch /var/log/odoo/odoo18.log
将 /opt/odoo/ 目录及其所有内容(包括子目录和文件),以及 /var/log/odoo/odoo12.log 文件的所有权更改为 odoo12 用户和 odoo 组。:
sudo chown -R odoo12:odoo /opt/odoo/odoo12-source/ /var/log/odoo/odoo12.log
sudo chown -R odoo13:odoo /opt/odoo/odoo13-source/ /var/log/odoo/odoo13.log
sudo chown -R odoo14:odoo /opt/odoo/odoo14-source/ /var/log/odoo/odoo14.log
sudo chown -R odoo15:odoo /opt/odoo/odoo15-source/ /var/log/odoo/odoo15.log
sudo chown -R odoo16:odoo /opt/odoo/odoo16-source/ /var/log/odoo/odoo16.log
sudo chown -R odoo17:odoo /opt/odoo/odoo17-source/ /var/log/odoo/odoo17.log
sudo chown -R odoo18:odoo /opt/odoo/odoo18-source/ /var/log/odoo/odoo18.log
六、安装Wkhtmltopdf用于odoo打印PDF,而且很怪的,只能用0.12.5这个版本:
直接安装
sudo apt install wkhtmltopdf
或者下载安装后补全依赖
cd /tmp && sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install -f
七、下载odoo源码,并创建odoo的conf系统配置文件:
下载自行想办法,用git clone也行,用迅雷拉包回来也行,各显神通:
分别配置odoo各版本的odoo.conf:
先在/etc目录下创建一个odoo文件夹:
sudo mkdir /etc/odoo/
顺便将odoo-bin给克隆出来:
sudo cp /opt/odoo/odoo12-source/setup/odoo /opt/odoo/odoo12-source/odoo-bin
sudo cp /opt/odoo/odoo13-source/setup/odoo /opt/odoo/odoo13-source/odoo-bin
sudo cp /opt/odoo/odoo14-source/setup/odoo /opt/odoo/odoo14-source/odoo-bin
sudo cp /opt/odoo/odoo15-source/setup/odoo /opt/odoo/odoo15-source/odoo-bin
sudo cp /opt/odoo/odoo16-source/setup/odoo /opt/odoo/odoo16-source/odoo-bin
sudo cp /opt/odoo/odoo17-source/setup/odoo /opt/odoo/odoo17-source/odoo-bin
sudo cp /opt/odoo/odoo18-source/setup/odoo /opt/odoo/odoo18-source/odoo-bin
再创建odoo.conf:
sudo cp /opt/odoo/odoo12-source/debian/odoo.conf /etc/odoo/odoo12.conf
sudo nano /etc/odoo/odoo12.conf
sudo cp /opt/odoo/odoo13-source/debian/odoo.conf /etc/odoo/odoo13.conf
sudo nano /etc/odoo/odoo13.conf
sudo cp /opt/odoo/odoo14-source/debian/odoo.conf /etc/odoo/odoo14.conf
sudo nano /etc/odoo/odoo14.conf
sudo cp /opt/odoo/odoo15-source/debian/odoo.conf /etc/odoo/odoo15.conf
sudo nano /etc/odoo/odoo15.conf
sudo cp /opt/odoo/odoo16-source/debian/odoo.conf /etc/odoo/odoo16.conf
sudo nano /etc/odoo/odoo16.conf
sudo cp /opt/odoo/odoo17-source/debian/odoo.conf /etc/odoo/odoo17.conf
sudo nano /etc/odoo/odoo17.conf
sudo cp /opt/odoo/odoo18-source/debian/odoo.conf /etc/odoo/odoo18.conf
sudo nano /etc/odoo/odoo18.conf
增加admin账套超级管理员密码,增加各版本不同的端口号:
Odoo12的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8029
db_host = False
db_port = False
db_user = odoo12
db_password = False
addons_path = /opt/odoo/odoo12-source/odoo/addons
logfile = /var/log/odoo/odoo12.log
Odoo13的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8039
db_host = False
db_port = False
db_user = odoo13
db_password = False
addons_path = /opt/odoo/odoo13-source/odoo/addons
logfile = /var/log/odoo/odoo13.log
Odoo14的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8049
db_host = False
db_port = False
db_user = odoo14
db_password = False
addons_path = /opt/odoo/odoo14-source/odoo/addons
logfile = /var/log/odoo/odoo14.log
Odoo15的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8059
db_host = False
db_port = False
db_user = odoo15
db_password = False
addons_path = /opt/odoo/odoo15-source/odoo/addons
logfile = /var/log/odoo/odoo15.log
Odoo16的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8069
db_host = False
db_port = False
db_user = odoo16
db_password = False
addons_path = /opt/odoo/odoo16-source/odoo/addons
logfile = /var/log/odoo/odoo16.log
Odoo17的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8079
db_host = False
db_port = False
db_user = odoo17
db_password = False
addons_path = /opt/odoo/odoo17-source/odoo/addons
logfile = /var/log/odoo/odoo17.log
Odoo18的conf配置:
[options]
; This is the password that allows database operations:
admin_passwd = admin
http_port = 8089
db_host = False
db_port = False
db_user = odoo18
db_password = False
addons_path = /opt/odoo/odoo18-source/odoo/addons
logfile = /var/log/odoo/odoo18.log
更改权限
sudo chown odoo12: /etc/odoo/odoo12.conf
sudo chmod 640 /etc/odoo/odoo12.conf
sudo chown odoo13: /etc/odoo/odoo13.conf
sudo chmod 640 /etc/odoo/odoo13.conf
sudo chown odoo14: /etc/odoo/odoo14.conf
sudo chmod 640 /etc/odoo/odoo14.conf
sudo chown odoo15: /etc/odoo/odoo15.conf
sudo chmod 640 /etc/odoo/odoo15.conf
sudo chown odoo16: /etc/odoo/odoo16.conf
sudo chmod 640 /etc/odoo/odoo16.conf
sudo chown odoo17: /etc/odoo/odoo17.conf
sudo chmod 640 /etc/odoo/odoo17.conf
sudo chown odoo18: /etc/odoo/odoo18.conf
sudo chmod 640 /etc/odoo/odoo18.conf
八、创建odoo的开机自启动服务:
sudo nano /etc/systemd/system/odoo12.service
sudo nano /etc/systemd/system/odoo13.service
sudo nano /etc/systemd/system/odoo14.service
sudo nano /etc/systemd/system/odoo15.service
sudo nano /etc/systemd/system/odoo16.service
sudo nano /etc/systemd/system/odoo17.service
sudo nano /etc/systemd/system/odoo18.service
添加odoo的开机自启动服务内容
Odoo12的开机自启动服务配置文件:
[Unit]
Description=odoo12
Documentation=odoo12-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo12
#ExecStart=/opt/odoo/odoo12-source/odoo-bin -c /etc/odoo12.conf
ExecStart=/opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12-source/odoo-bin -c /etc/odoo/odoo12.conf
[Install]
WantedBy=default.target
Odoo13的开机自启动服务配置文件:
[Unit]
Description=odoo13
Documentation=odoo13-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo13
#ExecStart=/opt/odoo/odoo13/odoo-bin -c /etc/odoo13.conf
ExecStart=/opt/odoo/odoo13-venv/bin/python3 /opt/odoo/odoo13-source/odoo-bin -c /etc/odoo/odoo13.conf
[Install]
WantedBy=default.target
Odoo14的开机自启动服务配置文件:
[Unit]
Description=odoo14
Documentation=odoo14-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo14
#ExecStart=/opt/odoo/odoo14/odoo-bin -c /etc/odoo14.conf
ExecStart=/opt/odoo/odoo14-venv/bin/python3 /opt/odoo/odoo14-source/odoo-bin -c /etc/odoo/odoo14.conf
[Install]
WantedBy=default.target
Odoo15的开机自启动服务配置文件:
[Unit]
Description=odoo15
Documentation=odoo15-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo15
#ExecStart=/opt/odoo/odoo15/odoo-bin -c /etc/odoo15.conf
ExecStart=/opt/odoo/odoo15-venv/bin/python3 /opt/odoo/odoo15-source/odoo-bin -c /etc/odoo/odoo15.conf
[Install]
WantedBy=default.target
Odoo16的开机自启动服务配置文件:
[Unit]
Description=odoo16
Documentation=odoo16-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo16
#ExecStart=/opt/odoo/odoo16/odoo-bin -c /etc/odoo16.conf
ExecStart=/opt/odoo/odoo16-venv/bin/python3 /opt/odoo/odoo16-source/odoo-bin -c /etc/odoo/odoo16.conf
[Install]
WantedBy=default.target
Odoo17的开机自启动服务配置文件:
[Unit]
Description=odoo17
Documentation=odoo17-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo17
#ExecStart=/opt/odoo/odoo17/odoo-bin -c /etc/odoo17.conf
ExecStart=/opt/odoo/odoo17-venv/bin/python3 /opt/odoo/odoo17-source/odoo-bin -c /etc/odoo/odoo17.conf
[Install]
WantedBy=default.target
Odoo18的开机自启动服务配置文件:
[Unit]
Description=odoo18
Documentation=odoo18-https://www.odoo123.com
[Service]
# Ubuntu/Debian convention:
Type=simple
User=odoo18
#ExecStart=/opt/odoo/odoo18/odoo-bin -c /etc/odoo18.conf
ExecStart=/opt/odoo/odoo18-venv/bin/python3 /opt/odoo/odoo18-source/odoo-bin -c /etc/odoo/odoo18.conf
[Install]
WantedBy=default.target
调整权限
sudo chmod 755 /etc/systemd/system/odoo12.service && sudo chown root: /etc/systemd/system/odoo12.service
sudo chmod 755 /etc/systemd/system/odoo13.service && sudo chown root: /etc/systemd/system/odoo13.service
sudo chmod 755 /etc/systemd/system/odoo14.service && sudo chown root: /etc/systemd/system/odoo14.service
sudo chmod 755 /etc/systemd/system/odoo15.service && sudo chown root: /etc/systemd/system/odoo15.service
sudo chmod 755 /etc/systemd/system/odoo16.service && sudo chown root: /etc/systemd/system/odoo16.service
sudo chmod 755 /etc/systemd/system/odoo17.service && sudo chown root: /etc/systemd/system/odoo17.service
sudo chmod 755 /etc/systemd/system/odoo18.service && sudo chown root: /etc/systemd/system/odoo18.service
查看odoo的log日志的方法:
sudo tail -f /var/log/odoo/odoo12.log
重新加载系统服务:
sudo systemctl daemon-reload
启动创建的odoo服务。
odoo12的:
sudo systemctl start odoo12
sudo systemctl restart odoo12
sudo systemctl enable odoo12
odoo13的:
sudo systemctl start odoo13
sudo systemctl restart odoo13
sudo systemctl enable odoo13
odoo14的:
sudo systemctl start odoo14
sudo systemctl restart odoo14
sudo systemctl enable odoo14
odoo15的:
sudo systemctl start odoo15
sudo systemctl restart odoo15
sudo systemctl enable odoo5
odoo16的:
sudo systemctl start odoo16
sudo systemctl restart odoo16
sudo systemctl enable odoo16
odoo17的:
sudo systemctl start odoo17
sudo systemctl restart odoo17
sudo systemctl enable odoo17
odoo18的:
sudo systemctl start odoo18
sudo systemctl restart odoo18
sudo systemctl enable odoo18
使它在启动时启动。
$ sudo systemctl enable odoo12
Created symlink /etc/systemd/system/multi-user.target.wants/odoo.service → /etc/systemd/system/odoo12.service.
确认Odoo服务是否设置为在启动时启动。
$ systemctl is-enabled odoo12
enabled
检查是否正在运行。
$ systemctl status odoo12
全文完毕。