使用“讓我們加密SSL”在CentOS 8上安裝Odoo 14
這篇文章旨在指導Linux用戶在CentOS 8上安裝Odoo14 ERP系統。 Odoo是具有POS,CRM,項目管理,網站構建器,市場營銷,倉庫管理,電子商務和計費功能的開源業務管理應用程序。 與會計,製造和許多其他很酷的功能。這些附加功能可以通過許多可以安裝的Odoo插件來解鎖。
在本文更新時,Odoo ERP軟件的最新版本為版本14。通過系統升級開始安裝,安裝所有必需的依賴項(例如PostgreSQL數據庫服務器),最後在CentOS 8上實際安裝Odoo ERP14。 Nginx用作CentOS8上Odoo14 ERP和CRM系統的前端代理。
步驟1:更新操作系統並設置主機名和DNS
登錄到CentOS 8服務器,執行系統更新,然後重新啟動。
sudo dnf -y update
sudo reboot
重新啟動系統後,配置正確的主機名。
sudo hostnamectl set-hostname erp.hirebestengineers.com --static
sudo hostnamectl set-hostname erp.hirebestengineers.com --transient
它還將有效的A記錄添加到DNS服務器。
保存記錄並運行ping或dig來驗證記錄是否正常。
$ sudo dnf -y install bind-utils
$ dig A erp.hirebestengineers.com +short
168.119.127.45
步驟2:將EPEL儲存庫添加到CentOS服務器
運行命令以將EPEL存儲庫添加到CentOS 8。
sudo yum -y install epel-release vim bash-completion
將SELinux置於可接受的模式。
sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
執行yumrepolist命令。
$ sudo yum repolist
repo id repo name
AppStream CentOS-8 - AppStream
BaseOS CentOS-8 - Base
epel Extra Packages for Enterprise Linux 8 - x86_64
epel-modular Extra Packages for Enterprise Linux Modular 8 - x86_64
extras CentOS-8 - Extras
步驟3:安裝PostgreSQL數據庫服務器
Odoo ERP資源庫使用PostgreSQL數據庫服務器進行數據存儲。該軟件包在DNF模塊中可用。
禁用當前的默認PostgreSQL模塊。
sudo dnf -qy module disable postgresql
啟用PostgreSQL 12模塊。
sudo dnf module -y enable postgresql:12
然後安裝PostgreSQL服務器和客戶端軟件包。
sudo dnf -y install @postgresql
安裝後,需要在啟動服務之前初始化數據庫。
$ sudo /usr/bin/postgresql-setup --initdb --unit postgresql
* Initializing database in '/var/lib/pgsql/data'
* Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
啟動並啟用數據庫服務器。
$ sudo systemctl enable --now postgresql
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /usr/lib/systemd/system/postgresql.service.
創建一個odoo數據庫用戶。
sudo su - postgres -c "createuser -s odoo"
步驟4:在CentOS 8上安裝wkhtmltopdf
Odoo使用wkhtmltopdf生成PDF格式的報告。推薦安裝的wkhtmltopdf版本為0.12.5,可從存檔部分的wkhtmltopdf下載頁面獲得。
sudo dnf install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos8.x86_64.rpm
檢查安裝的版本。
$ wkhtmltopdf --version wkhtmltopdf 0.12.5 (with patched qt)
在CentOS 8上實際安裝Odoo 14的下一步。
步驟5:在CentOS 8上安裝Odoo 14
添加一個EPEL存儲庫。
yum -y install epel-release
同時啟用PowerTools存儲庫。
sudo dnf config-manager --set-enabled PowerTools
安裝Python和其他構建依賴項。
sudo yum -y install vim bash-completion zip git gcc openldap-devel python3 python3-devel redhat-rpm-config libxslt-devel libjpeg-devel freetype-devel bzip2-devel
為Odoo系統添加用戶和組。
sudo useradd -r -m -U -d /opt/odoo -s /bin/bash odoo
為創建的用戶帳戶設置密碼。
$ sudo passwd odoo
Changing password for user odoo.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
檢查用戶詳細信息。
$ id odoo
uid=992(odoo) gid=989(odoo) groups=989(odoo)
切換到您創建的用戶帳戶。
$ sudo su - odoo
從Github克隆版本14分支。
git -C /opt/odoo/ clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0
創建一個PythonVirtualenv。
cd /opt/odoo
python3 -m venv odoo-venv
激活您創建的虛擬環境。
source odoo-venv/bin/activate
在需求文件中安裝Python依賴項。
pip3 install -r odoo/requirements.txt
如果安裝成功完成,則將停用虛擬環境。
deactivate
exit
創建一個Odoo日誌文件。
sudo touch /var/log/odoo.log
創建自定義加載項路徑:
sudo mkdir /opt/odoo/odoo/custom-addons
設置正確的目錄權限。
sudo chown -R odoo:odoo /opt/odoo/ /var/log/odoo.log
創建一個Odoo實例配置文件。
sudo tee /etc/odoo.conf<<EOF
[options]
proxy_mode = True
; This is the password that allows database operations:
admin_passwd = [email protected]
db_host = False
db_port = False
db_user = odoo
db_password = False
xmlrpc_port = 8069
logfile = /var/log/odoo.log
logrotate = True
addons_path = /opt/odoo/odoo/addons,/opt/odoo/odoo/custom-addons
EOF
創建一個Systemd服務單元文件。
sudo tee /etc/systemd/system/odoo.service<<EOF
[Unit]
Description=Odoo ERP Server
Requires=postgresql.service
After=network.target postgresql.service
[Service]
User=odoo
Group=odoo
Type=simple
SyslogIdentifier=odoo
PermissionsStartOnly=true
ExecStart=/opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
EOF
系統服務重載:
sudo systemctl daemon-reload
啟動創建的doo服務。
sudo systemctl start odoo
sudo systemctl restart odoo
允許您在啟動時開始。
$ sudo systemctl enable odoo
Created symlink /etc/systemd/system/multi-user.target.wants/odoo.service → /etc/systemd/system/odoo.service.
檢查Odoo服務是否設置為在啟動時啟動。
$ systemctl is-enabled odoo
enabled
檢查它是否正在運行。
$ systemctl status odoo
● odoo.service - Odoo ERP Server
Loaded: loaded (/etc/systemd/system/odoo.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2020-10-11 18:38:30 CEST; 48s ago
Main PID: 25201 (python3)
Tasks: 4 (limit: 24392)
Memory: 59.2M
CGroup: /system.slice/odoo.service
└─25201 /opt/odoo/odoo-venv/bin/python3 /opt/odoo/odoo/odoo-bin -c /etc/odoo.conf
Oct 11 18:38:30 erp.hirebestengineers.com systemd[1]: Started Odoo ERP Server.
Odoo服務必須綁定到TCP端口 8069 它開始一次。
$ sudo ss -tunelp | grep 8069
tcp LISTEN 0 128 0.0.0.0:8069 0.0.0.0:* users:(("python3",pid=25201,fd=4)) uid:992 ino:64882 sk:5 <->
步驟6:配置Nginx代理(無SSL)–不推薦
在CentOS8上安裝Nginx Web Server。
sudo yum -y install nginx
sudo systemctl enable --now nginx
為odoo創建一個新的配置文件。
sudo vim /etc/nginx/conf.d/odoo.conf
修改此配置代碼片段以適合您的設置。
# Odoo Upstreams
upstream odooserver {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name erp.hirebestengineers.com;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# Request for root domain
location / {
proxy_redirect off;
proxy_pass http://odooserver;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odooserver;
}
# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
交換 erp.computingforgeeks 使用域名驗證Nginx配置文件。
$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
如果一切順利,請重新啟動Nginx。
sudo systemctl restart nginx
步驟7:配置Nginx代理(使用SSL證書)–推薦
如果您的服務器具有公共IP,則可以為您的域創建DNS A記錄,指向您的Odoo服務器,然後申請免費的Let’s Encrypt SSL證書。
在CentOS8服務器上安裝Nginx。
sudo yum -y install nginx
sudo systemctl enable --now nginx
安裝certbot-auto工具。
sudo yum -y install wget
wget https://dl.eff.org/certbot-auto
chmod +x certbot-auto
sudo mv certbot-auto /usr/local/bin/certbot-auto
停止Nginx服務。
sudo systemctl stop nginx
加密您域的SSL證書。
export DOMAIN="erp.hirebestengineers.com"
export EMAIL="[email protected]"
sudo /usr/local/bin/certbot-auto certonly --standalone -d ${DOMAIN} --preferred-challenges http --agree-tos -n -m ${EMAIL} --keep-until-expiring
證書文件的路徑為“重要筆記“ 部分。
IMPORTANT NOTES: Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/erp.hirebestengineers.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/erp.hirebestengineers.com/privkey.pem Your cert will expire on 2021-01-09. To obtain a new or tweaked version of this certificate in the future, simply run certbot-auto again. To non-interactively renew all of your certificates, run "certbot-auto renew" Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
創建證書更新的cron。
$ sudo crontab -e
15 3 * * * /usr/local/bin/certbot-auto renew --pre-hook "systemctl stop nginx" --post-hook "systemctl start nginx"
創建一個Nginx配置文件。
sudo vim /etc/nginx/conf.d/odoo.conf
將以下內容粘貼到文件中 更改 它適合您的環境。
# Odoo Upstreams
upstream odooserver {
server 127.0.0.1:8069;
}
# http to https redirection
server {
listen 80;
server_name erp.hirebestengineers.com;
return 301 https://erp.hirebestengineers.com$request_uri;
}
server {
listen 443 ssl;
server_name erp.hirebestengineers.com;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;
# SSL
ssl_certificate /etc/letsencrypt/live/erp.hirebestengineers.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/erp.hirebestengineers.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/erp.hirebestengineers.com/chain.pem;
# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
# Request for root domain
location / {
proxy_redirect off;
proxy_pass http://odooserver;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odooserver;
}
# Gzip Compression
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
驗證Nginx配置。
$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
重新啟動Nginx。
sudo systemctl restart nginx
步驟8:在CentOS 8服務器上訪問Odoo 14
從Web上訪問域名Odoo網頁– https:// DNS主機名。
您也可以直接訪問Odoo網頁。
http://<your_server_IP_address>:8069
在第一頁上,設置數據庫名稱,管理員用戶電子郵件地址和管理員用戶密碼。
Odoo ERP現在已安裝並在您的CentOS 8服務器上運行。檢查我們的網站以獲取最新文章。
有關CentOS 8的其他文章:
如何在CentOS 8上安裝Micro K8s Kubernetes集群
如何使用Rent的CentOS 8配置TigerVNC
在CentOS 8上安裝Google Hangout Client