筆者使用的是ubuntu20.04來建立odoo16環境
首先開啟ubuntu terminal,輸入指令:
sudo apt install postgresql postgresql-cotrib
sudo systemctl status//start postgresql
來安裝PostgreSQL,可以透過以下指令來進入PostgreSQL當中:
sudo -i -u postgres
psql
\q
exit
再來就是安裝odoo16前,先安裝好需要的套件:
sudo apt install wkhtmltopdf
sudo apt install ttf-mscorefonts-installer
sudo apt-get install fonts-wqy-zenhei
sudo apt-get install fonts-wqy-microhei
sudo apt-get install nodejs npm -y
sudo npm install -g rtlcss
還有需要的工具:
sudo apt install git
sudo apt install python
sudo apt install python3-venv
python3 -m venv odoo16
pip install wheel
再來就可以安裝odoo16了:
source ~/odoo16/bin/activate
pip install -r requirements.txt
在執行pip install -r requirements.txt
時,容易發生問題,以下是筆者安裝的套件:
sudo apt-get install build-essential python3-dev libldap2-dev libssl-dev
pip install --upgrade pip
pip install python-ldap
sudo apt install libpq-dev
pip install psycopg2-binary
套件安裝完後基本上就可以執行odoo16了,建議在執行以前先再輸入指令pip install -r requirements.txt
確認沒有錯誤。
執行odoo前,一樣我們會先製作一個config:
mkdir config
nano ./config/odoo.conf
[options]
addons_path = ~/odoo/addons,~/odoo/odoo/addons
admin_passwd = 123456789
db_host = localhost
db_port = 5432
db_user = odoo
db_password = odoo
xmlrpc_interface = 127.0.0.1
xmlrpc_port =8069
http_port = 8069
讀者會發現,多了一些之前沒看過的設定碼,這是為了架設到Nginx上做的準備。
最後我們就可以運行odoo16了python odoo-bin -c ./config/odoo.conf
以下是設定Nginx的指令:
sudo apt update
sudo apt upgrade
sudo apt install nginx
sudo rm /etc/nginx/sites-enabled/default
sudo rm /etc/nginx/sites-available/default
sudo nano /etc/nginx/sites-available/odoo.conf
首先我們安裝nginx後,來到nginx設定odoo.conf:
upstream odoo {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name odoo;
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://odoo;
proxy_redirect off;
}
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo;
}
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
再來將odoo.conf給link好,重啟Nginx
sudo ln -s /etc/nginx/sites-available/odoo.conf /etc/nginx/sites-enabled/odoo.conf
sudo nginx -t
sudo systemctl restart nginx
這樣我們基本上就設定好Nginx了。