Raspberry Pi安裝Odoo14紀錄

整理樹莓派安裝Odoo社區版的開源ERP系統的終端指令,
使用的系統版本為Raspberry Pi OS with desktop 32bit(May 7th 2021) ,
其他作業系統操作會有些許出入(下半篇有x86 Ubuntu安裝紀錄)。

Odoo常見擴充功能

#更新系統軟體

sudo apt update && sudo apt upgrade -y

#安裝資料庫

sudo apt-get install postgresql -y

#安裝常用py程序

sudo apt install python3-pip -y

#安裝odoo開立收據用PDF工具

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.raspberrypi.buster_armhf.deb && sudo apt install ./wkhtmltox_0.12.6-1.raspberrypi.buster_armhf.deb -y

#開立收據用PDF工具中文字形

sudo apt install fonts-wqy-microhei ttf-wqy-microhei fonts-wqy-zenhei ttf-wqy-zenhei -y

#清理快取

fc-cache -f -v

#此為修復apt安裝程序,可忽略

sudo apt --fix-broken install

#新增使用者

sudo adduser odoo

#新增資料夾

sudo mkdir /var/lib/odoo

#取最新版odoo安裝包

wget http://nightly.odoo.com/14.0/nightly/deb/odoo_14.0.latest_all.deb

#安裝odoo最新版

sudo apt install ./odoo_14.0.latest_all.deb -y

#安裝Nginx反代(前端用,可改裝於叢集)

sudo apt install nginx -y

#編輯預設網站檔(這裡只是拿預設的網站檔來改,實際上請針對需要的網域修改)

sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/defaultv2
sudo vi /etc/nginx/sites-available/default


****預設網站檔**開始**

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    location /health {
            access_log off;
            return 200 "healthy\n";
    }
    location / {
            proxy_pass http://localhost:8069; 
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_cache_bypass $http_upgrade;
    }
  }

****預設網站檔**結束**


#此為預設網站檔加入SSL憑證與快取參考

----SSLCache--開始----

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
    server_name _;
  }
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name _;
    ssl_certificate /etc/nginx/ssl/odoo.crt;
    ssl_certificate_key /etc/nginx/ssl/odoo.key;
    location ~* \.(avif|bmp|ejs|jpeg|pdf|ps|ttf|class|eot|jpg|pict|svg|webp|css|eps|js|pls|svgz|woff|csv|gif|mid|png|swf|woff2|doc|ico|midi|ppt|tif|xls|docx|jar|otf|pptx|tiff|xlsx)$
{
proxy_pass http://localhost:8069;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    expires 168h;
    
    add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
    proxy_ignore_headers Set-Cookie Cache-Control expires;
    proxy_cache cache_one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 304 301 302 4320m;
}
location /
{
    proxy_pass http://localhost:8069;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

}
  }

----SSLCache--結束----

#重啟Nginx

service nginx restart


#Nginx反代外部網域引用開放跨站請求

###CORS###

    add_header 'Access-Control-Allow-Origin' *;
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';


#創建Nginx全域反代設定

sudo vi /etc/nginx/conf.d/cache.conf

-----cache.conf--開始--

proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache_one:10m inactive=1d max_size=10g;
proxy_cache_key '$scheme$host$request_uri';

-----cache.conf--結束--

#創建緩存資料夾

sudo mkdir -p /var/cache/nginx/cache

#重建設定值

sudo nginx -c /etc/nginx/nginx.conf

#重啟Nginx

sudo nginx -s reload

上述是樹莓派的操作,底下附上常見x86 Ubuntu安裝過程

2021/10/20更新 在Ubuntu20.04 LTS安裝紀錄

#前置操作

sudo apt update && sudo apt upgrade -y && sudo apt-get install postgresql -y && sudo apt install python3-pip -y


#安裝odoo開立收據用PDF工具(與下方備選方案擇一)

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && sudo apt-get install xfonts-75dpi -y && sudo dpkg -i ./wkhtmltox_0.12.6-1.focal_amd64.deb


#安裝odoo開立收據用PDF工具(備選方案)

###wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb -y


#開立收據用PDF工具中文字形與清快取

sudo apt install fonts-wqy-microhei ttf-wqy-microhei fonts-wqy-zenhei ttf-wqy-zenhei -y && fc-cache -f -v


#修復安裝錯誤(可忽略)

###apt --fix-broken install


#創建odoo用戶

sudo adduser odoo


#安裝odoo14

sudo mkdir /var/lib/odoo && wget http://nightly.odoo.com/14.0/nightly/deb/odoo_14.0.latest_all.deb && sudo apt install ./odoo_14.0.latest_all.deb -y


#安裝Nginx

sudo apt install nginx -y


#編輯預設網站

sudo mv /etc/nginx/sites-available/default /etc/nginx/sites-available/defaultv2
sudo vi /etc/nginx/sites-available/default


#預設網站文件範本

------------------SSLCache------------------

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
    server_name _;
  }
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name _;
    ssl_certificate /etc/nginx/ssl/odoo.crt;
    ssl_certificate_key /etc/nginx/ssl/odoo.key;
    location ~* \.(avif|bmp|ejs|jpeg|pdf|ps|ttf|class|eot|jpg|pict|svg|webp|css|eps|js|pls|svgz|woff|csv|gif|mid|png|swf|woff2|doc|ico|midi|ppt|tif|xls|docx|jar|otf|pptx|tiff|xlsx)$
{
proxy_pass http://localhost:8069;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    expires 168h;
    
    ###CORS###
    add_header 'Access-Control-Allow-Origin' *;
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';

    add_header X-Cache $upstream_cache_status;


#Set Nginx Cache
    proxy_ignore_headers Set-Cookie Cache-Control expires;
    proxy_cache cache_one;
    proxy_cache_key $host$uri$is_args$args;
    proxy_cache_valid 200 304 301 302 4320m;
}
location /
{
    proxy_pass http://localhost:8069;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;

}
  }

------------------SSLCache------------------


#創建Nginx全域反代設定

sudo vi /etc/nginx/conf.d/cache.conf

-----cache.conf------

proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=cache_one:10m inactive=1d max_size=10g;
proxy_cache_key '$scheme$host$request_uri';

-----cache.conf------


#創建緩存資料夾

sudo mkdir -p /var/cache/nginx/cache


#創建憑證資料夾

sudo mkdir -p /etc/nginx/ssl


#寫入憑證

sudo vi /etc/nginx/ssl/odoo.crt
sudo vi /etc/nginx/ssl/odoo.key


#重建設定值

sudo nginx -c /etc/nginx/nginx.conf

#重啟Nginx

sudo nginx -s reload

###備註一下,wkhtmltopdf工具在處理RGBA色彩模型會嚴重拖慢性能,
Odoo最好可以修改一下css引入的元素,不想花時間可以到

Odoo設定>常規設定>商業文件>文件格式>設置文件格式
佈局選擇不帶任何框線的Clean即可。

Odoo設定>常規設定>商業文件>文件格式>設置文件格式


佈局選擇不帶任何框線的Clean

留言

這個網誌中的熱門文章

華為HUAWEI B525 4G分享器簡易開箱測試

Hugiga L66長輩機 搭配 亞太 遠傳門號簡易開箱