1. 程式人生 > 其它 >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

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 完成---------------------