odoo14-Ubuntu20安装Odoo14

为了方便后面的看客老爷们的极致体验, 本人在代码中都会把路径写进来,希望各位看客老爷们参考的时候多留意-路径跟代码我会分行显示

一.换源: 确保后面安装python库的速度提升

1.备份原来的源

ubuntu@VM-4-15-ubuntu:~$ 
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.进入文件选择合适的国内源

ubuntu@VM-4-15-ubuntu:~$ 
sudo vim /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse

3.刷新软件源信息

ubuntu@VM-4-15-ubuntu:~$ 
sudo apt-get update

4.更新软件-试试速度提升的感觉 奖励一下自己

ubuntu@VM-4-15-ubuntu:~$ 
sudo apt-get upgrade

二.先决条件

1.以下命令安装 Git,Pip, Node.js 和构建所需的工具

  • 注意: 这些工具可能会在后面安装requirement.txt里面的python库的时候需要更新工具的版本,这个得自己摸索,先安装,后面根据错误提示自行安装对应的工具版本
ubuntu@VM-4-15-ubuntu:~$ 
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

三.开始搭建Odoo14相关

1.创建系统用户

  • 不允许在root用户下运行Odoo,因为这存在安全风险。 所以需要创建一个新的系统用户,并与将运行Odoo服务的主目录/opt/odoo14进行分组
  • 可以使用任意名称为用户命名,只要后面创建具有相同名称的PostgreSQL用户即可
ubuntu@VM-4-15-ubuntu:~$ 
sudo useradd -m -d /opt/odoo14 -U -r -s /bin/bash odoo14

2.安装和配置PostgreSQL

2.1.安装
ubuntu@VM-4-15-ubuntu:~$ 
sudo apt install postgresql
2.2.创建一个与先前创建的系统用户同名的PostgreSQL用户
ubuntu@VM-4-15-ubuntu:~$ 
sudo su - postgres -c "createuser -s odoo14"

3.安装wkhtmltopdf(可不操作-安装的作用是为了打印报表等,不安装也不影响odoo使用)

3.1下载
ubuntu@VM-4-15-ubuntu:~$ 
sudo wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.bionic_amd64.deb
  • 因为是从github下载的,可能会很慢,我建议直接去官网下载对应的版本,然后放到指定路径的文件夹
ubuntu@VM-4-15-ubuntu:~$ pwd
/home/ubuntu
3.2.安装
ubuntu@VM-4-15-ubuntu:~$ 
sudo apt-get install ./wkhtmltox_0.12.6-1.focal_amd64.deb
  • 后面的.deb是根据自己下载的版本来的,看客老爷们千万别复制成本人这个了

4.安装和配置Odoo14

4.1.切换到odoo14用户
ubuntu@VM-4-15-ubuntu:~$ 
sudo su - odoo14
4.2.下载odoo14源码
odoo14@VM-4-15-ubuntu:~$
git clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0 /opt/odoo14/odoo
4.3.创建虚拟环境
4.3.1.切换路径
odoo14@VM-4-15-ubuntu:~$ 
cd /opt/odoo14
4.3.2.创建虚拟环境
odoo14@VM-4-15-ubuntu:~$ 
python3 -m venv odoo-venv
4.3.3.激活虚拟环境
odoo14@VM-4-15-ubuntu:~$ 
source odoo-venv/bin/activate
(odoo-venv) odoo14@VM-4-15-ubuntu:~$
4.4.安装必需的Python模块
(odoo-venv) odoo14@VM-4-15-ubuntu:~$ 
pip3 install wheel
(odoo-venv) odoo14@VM-4-15-ubuntu:~$ 
pip3 install -r odoo/requirements.txt
  • ps:鸡冻,无数次重装下,第一次在写博客的时候直接装成功所有的模块
4.5.停用环境
(odoo-venv) odoo14@VM-4-15-ubuntu:~$ 
deactivate
odoo14@VM-4-15-ubuntu:~$
4.6.退回到root用户
odoo14@VM-4-15-ubuntu:~$ 
exit
ubuntu@VM-4-15-ubuntu:~$
4.7.创建系统配置文件
ubuntu@VM-4-15-ubuntu:~$ 
sudo nano /etc/odoo14.conf
[options]
; This is the password that allows database operations:
admin_passwd = xxxxxxx
db_host = localhost
db_port = 5432 
db_user = odoo14 
db_password = xxxxx
addons_path = /opt/odoo14/odoo/addons

四.启动服务

1.创建systemd Unit文件

1.1.创建配置文件
ubuntu@VM-4-15-ubuntu:~$ 
sudo nano /etc/systemd/system/odoo14.service
1.2.配置文件
[Unit]
Description=Odoo14
Requires=postgresql.service
After=network.target postgresql.service

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

[Install]
WantedBy=multi-user.target
1.3.通知systemd一个新的Unit单位文件存在
ubuntu@VM-4-15-ubuntu:~$ 
sudo systemctl daemon-reload

2.启动Odoo服务,并通过运行以下命令使其在启动时启动

2.1.启动odoo服务
ubuntu@VM-4-15-ubuntu:~$ 
sudo systemctl enable --now odoo14
2.2.验证odoo服务状态
ubuntu@VM-4-15-ubuntu:~$ 
sudo systemctl status odoo14
  • 此时的日志
● odoo14.service - Odoo14
     Loaded: loaded (/etc/systemd/system/odoo14.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-29 11:45:56 CST; 1min 8s ago
   Main PID: 122914 (python3)
      Tasks: 4 (limit: 4608)
     Memory: 63.5M
     CGroup: /system.slice/odoo14.service
             └─122914 /opt/odoo14/odoo-venv/bin/python3 /opt/odoo14/odoo/odoo-bin -c /etc/odoo14.conf

Sep 29 11:45:56 VM-4-15-ubuntu systemd[1]: Started Odoo14.
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,422 122914 INFO ? odoo: Odoo version 14.0
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: Using configuration file at /etc/odoo14.conf
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: addons paths: ['/opt/odoo14/odoo/odoo/addons', '/opt/odoo14/.local/share/Odoo/addons/14.0', '/opt/odoo14/odoo/addons']
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: database: odoo14@localhost:5432
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,595 122914 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,807 122914 INFO ? odoo.service.server: HTTP service (werkzeug) running on localhost.localdomain:8069
2.3.查看Odoo服务记录的消息
ubuntu@VM-4-15-ubuntu:~$ 
sudo journalctl -u odoo14
  • 此时的日志
-- Logs begin at Wed 2021-09-29 10:23:55 CST, end at Wed 2021-09-29 11:49:04 CST. --
Sep 29 11:45:56 VM-4-15-ubuntu systemd[1]: Started Odoo14.
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,422 122914 INFO ? odoo: Odoo version 14.0
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: Using configuration file at /etc/odoo14.conf
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: addons paths: ['/opt/odoo14/odoo/odoo/addons', '/opt/odoo14/.local/share/Odoo/addons/14.0', '/opt/odoo14/odoo/addons']
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,423 122914 INFO ? odoo: database: odoo14@localhost:5432
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,595 122914 INFO ? odoo.addons.base.models.ir_actions_report: Will use the Wkhtmltopdf binary at /usr/local/bin/wkhtmltopdf
Sep 29 11:45:57 VM-4-15-ubuntu odoo14[122914]: 2021-09-29 03:45:57,807 122914 INFO ? odoo.service.server: HTTP service (werkzeug) running on localhost.localdomain:8069

五.前面的步骤对了,但是服务启动不起来

注意注意!!!
这个时候看似没有错误,如果你直接去网页访问你自己的服务器ip:8069 就会提示内部服务器错误
这个时候你再回去看看状态以及日志信息,就会发现

ubuntu@VM-4-15-ubuntu:~$ sudo systemctl status odoo14
● odoo14.service - Odoo14
     Loaded: loaded (/etc/systemd/system/odoo14.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2021-09-29 11:45:56 CST; 5min ago
   Main PID: 122914 (python3)
      Tasks: 4 (limit: 4608)
     Memory: 69.9M
     CGroup: /system.slice/odoo14.service
             └─122914 /opt/odoo14/odoo-venv/bin/python3 /opt/odoo14/odoo/odoo-bin -c /etc/odoo14.conf

Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:   File "/opt/odoo14/odoo/odoo/sql_db.py", line 248, in __init__
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:     self._cnx = pool.borrow(dsn)
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:   File "/opt/odoo14/odoo/odoo/sql_db.py", line 558, in _locked
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:     return fun(self, *args, **kwargs)
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:   File "/opt/odoo14/odoo/odoo/sql_db.py", line 624, in borrow
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:     result = psycopg2.connect(
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:   File "/opt/odoo14/odoo-venv/lib/python3.8/site-packages/psycopg2/__init__.py", line 127, in connect
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]:     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]: psycopg2.OperationalError: FATAL:  password authentication failed for user "odoo14"
Sep 29 11:51:18 VM-4-15-ubuntu odoo14[122914]: FATAL:  password authentication failed for user "odoo14" - - -

会提示odoo14用户的密码错误,这个时候想到的就是去pg数据库更换用户14的密码

1.操作PostgreSQL

1.1.登录PostgreSQL
ubuntu@VM-4-15-ubuntu:~$ 
sudo -u postgres psql
1.2.修改登录PostgreSQL密码
postgres=# ALTER USER odoo14 WITH PASSWORD 'newpassword';
ALTER ROLE
1.3.退出PostgreSQL
postgres=# \q
1.4.重启PostgreSQL
ubuntu@VM-4-15-ubuntu:~$ 
sudo service postgresql restart

你可能感兴趣的:(Odoo,postgresql,ubuntu,git)