Follow the below steps to install Odoo 14 on Ubuntu 20.04 LTS

Follow the below steps to install Odoo 14 on Ubuntu 20.04 LTS

注意:

1、创建系统用户 odoo,文件sudo nano /etc/systemd/system/odoo.service 中需要设置 ;

2、创建 postgresql 用户 odoo_14和密码 odoo14, 文件sudo nano /etc/systemd/system/odoo.service中需要设置用户和密码;

3、文件 sudo nano /etc/postgresql/12/main/pg_hba.conf 中需要增加用户;

Step-1: Keep update your Server

sudo apt-get update
sudo apt-get upgrade

Step 2: Secure your system

sudo apt-get install openssh-server fail2ban

Step 3: Create a system user

sudo adduser --system --home=/opt/odoo --group odoo

Step 4: Installing Packages and libraries

Install pip3:

sudo apt-get install -y python3-pip

Install Packages and libraries:

sudo apt-get install python-dev python3-dev libxml2-dev libxslt1-dev zlib1g-dev libsasl2-dev libldap2-dev build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libpq-dev libjpeg8-dev liblcms2-dev libblas-dev libatlas-base-dev

Ensure that all packages are successfully installed. Moreover, there are some web dependencies that also need to be installed.

sudo apt --fix-broken install
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less less-plugin-clean-css
sudo apt-get install -y node-less

Step: 5: Configure Postgresql

sudo apt-get install postgresql
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo_14
psql
ALTER USER odoo_14 WITH SUPERUSER;
\q
exit

在postgres配置文件中增加创建的odoo_14用户:

sudo nano /etc/postgresql/12/main/pg_hba.conf
 
local   all             postgres                                peer
local   all             odoo_14                                 md5

Step 6: Get Odoo community from git

sudo apt-get install git

Now before cloning, we have to change the system user as odoo (which is created in Step 3) to make the Odoo system more secure.

sudo su - odoo -s /bin/bash
git clone https://gitee.com/mirrors/odoo  --depth 1 --branch 14.0  --single-branch .
exit

Source files are cloned to the home directory of user odoo. Moreover, the home directory of the user is specified at the time of user creation. Which is /opt/odoo.
Now exit and continue with the installation.

Step 7: Install required python packages 或换成gitee中的包

sudo pip3 install -r /opt/odoo/requirements.txt
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install -f
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb

或换成gitee中的包

sudo wget https://gitee.com/wkhtmltopdf/wkhtmltopdf/attach_files/662857/download/wkhtmltox_0.12.5-1.bionic_amd64.deb

Step 8: Configuration of Odoo,db_user和db_password需修改为上面第5步创建的。

sudo cp /opt/odoo/debian/odoo.conf /etc/odoo.conf
sudo nano /etc/odoo.conf

[options]
   ; This is the password that allows database operations:
   admin_passwd = admin
   db_host = False
   db_port = False
   db_user = odoo_14
   db_password = odoo14
   addons_path = /opt/odoo/addons
   logfile = /var/log/odoo/odoo.log

sudo chown odoo: /etc/odoo.conf
sudo chmod 640 /etc/odoo.conf
sudo mkdir /var/log/odoo
sudo chown odoo:root /var/log/odoo

Step 9: Create new service for odoo

sudo nano /etc/systemd/system/odoo.service
[Unit]
   Description=Odoo
   Documentation=http://www.odoo.com
   [Service]
   # Ubuntu/Debian convention:
   Type=simple
   User=odoo
   ExecStart=/opt/odoo/odoo-bin -c /etc/odoo.conf
   [Install]
   WantedBy=default.target
sudo chmod 755 /etc/systemd/system/odoo.service
sudo chown root: /etc/systemd/system/odoo.service

Step 10: Run Odoo 14

sudo systemctl start odoo.service
sudo systemctl status odoo.service
sudo systemctl restart odoo.service
sudo systemctl daemon-reload

“http://<your_domain_or_IP_address>:8069”

sudo tail -f /var/log/odoo/odoo.log

If you need Odoo service to start automatically on boot time, you can use the following command.

sudo systemctl enable odoo.service

Step 11: 重启服务器

ubuntu@VM-0-11-ubuntu:~$ sudo reboot

---------------完成---------------------

Setp 11:安装宝塔进行管理文件及设置Nginx代理。

sudo apt-get install nginx
nginx -v
cd /etc/nginx/conf.d
sudo touch odoo_skydba.conf
sudo vi odoo_skydba.conf
upstream odoo {
        server 127.0.0.1:8069;
}
server {
        listen 80;
        server_name www.skydba.com;
        location / {
        # 后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X_Nginx_Proxy true;
        proxy_pass http://odoo;
        proxy_redirect off;
        }
}
server{
    listen 80;
    server_name odoo.lecc.cn; #绑定域名
    index index.htm index.html index.php; #默认文件
    root /home/www/msn.itblood.com; #网站根目录
    include location.conf; #调用其他规则,也可去除
}
sudo vi /etc/nginx/conf.d/odoo_skydba.conf

ssl证书上传到/etc/nginx

upstream odoo {
        server 127.0.0.1:8069;
}
server {
        listen 443 ssl;
         server_name www.skydba.com;
         #证书文件名称
         ssl_certificate 1_www.skydba.com_bundle.crt;
         #私钥文件名称
         ssl_certificate_key 2_www.skydba.com.key;
         ssl_session_timeout 5m;
         #请按照以下协议配置
         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
         #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
         ssl_prefer_server_ciphers on;
        location / {
        # 后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X_Nginx_Proxy true;
        proxy_pass http://odoo;
        proxy_redirect off;
        }
}

启动Nginx并设置开机自动运行

sudo systemctl start nginx.service
sudo systemctl enable nginx.service
sudo systemctl stop nginx.service
systemctl status nginx
nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确

关闭nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
kill -QUIT 主进程号 :从容停止Nginx
kill -TERM 主进程号 :快速停止Nginx
pkill -9 nginx :强制停止Nginx
启动nginx:
nginx -c /path/to/nginx.conf
平滑重启nginx:
kill -HUP 主进程

上传文件大小限制修改 在配置文件http中加入下面配置

client_max_body_size 50M;
ubuntu@VM-0-11-ubuntu:~$ sudo vi /etc/nginx/nginx.conf

ubuntu@VM-0-11-ubuntu:~$ sudo nginx -s reload

ubuntu@VM-0-11-ubuntu:~$ sudo systemctl stop nginx.service

ubuntu@VM-0-11-ubuntu:~$ sudo systemctl start nginx.service

---------------Nginx 完成---------------------

posted @ 2021-08-13 13:36  SkyDBA  阅读(138)  评论(0)    收藏  举报