如何在 Debian Linux 上安装 Odoo ERP
Odoo,也称为OpenERP,是一个基于Python的免费开源企业资源规划应用程序。它是一个功能齐全的应用程序,包括开源CRM、销售点、人力资源管理、销售点、发票和会计、事件管理、电子邮件营销、订单跟踪等。它是一个开源业务应用程序套件满足您所有的业务需求。
这篇文章将向您展示如何在 Debian 上使用 Nginx 和 Let’s Encrypt SSL 安装 Odoo14。
要求
- 运行 Debian 11 的服务器。
- 指向您服务器 IP 的有效域名。
- 服务器上配置的 root 密码。
安装 PostgreSQL 服务器
在开始之前,您必须在服务器上安装 PostgreSQL 服务器。默认情况下,最新版本的 PostgreSQL 不包含在默认的 Debian 11 存储库中。因此,您需要将 PostgreSQL 存储库添加到您的服务器。
首先,使用以下命令安装所需的依赖项:
apt-get install gnupg2 wget curl -y
接下来,使用以下命令添加 PostgreSQL GPG 密钥和存储库:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
添加存储库后,使用以下命令更新存储库并安装 PostgreSQL:
apt-get update -y
apt-get install postgresql-12 postgresql-client-12 -y
安装 PostgreSQL 后,使用以下命令检查 PostgreSQL 的状态:
systemctl status postgresql
您应该得到以下输出:
? postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2021-09-20 11:19:33 UTC; 20s ago
Main PID: 3746 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4679)
Memory: 0B
CPU: 0
CGroup: /system.slice/postgresql.service
Sep 20 11:19:33 debian11 systemd[1]: Starting PostgreSQL RDBMS...
Sep 20 11:19:33 debian11 systemd[1]: Finished PostgreSQL RDBMS.
接下来,您需要在服务器上安装 wkhtmltopdf 软件包。您可以使用以下命令安装它:
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb
apt-get install ./wkhtmltox_0.12.6-1.buster_amd64.deb
安装Odoo14
默认情况下,Odoo14 不包含在 Debian 11 默认存储库中。因此,您需要将 Odoo14 存储库添加到您的服务器。
您可以使用以下命令添加 Odoo14 存储库:
wget -O - https://nightly.odoo.com/odoo.key | apt-key add -
echo "deb http://nightly.odoo.com/14.0/nightly/deb/ ./" | tee /etc/apt/sources.list.d/odoo.list
添加存储库后,使用以下命令更新它并安装 Odoo14:
apt-get update -y
apt-get install odoo -y
安装完成后,启动Odoo14服务并使其在重启系统时启动:
systemctl enable --now odoo
您可以使用以下命令检查 Odoo14 的状态:
systemctl status odoo
输出 :
? odoo.service - Odoo Open Source ERP and CRM
Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-09-20 11:22:35 UTC; 29s ago
Main PID: 11356 (odoo)
Tasks: 4 (limit: 4679)
Memory: 65.3M
CPU: 1.512s
CGroup: /system.slice/odoo.service
??11356 /usr/bin/python3 /usr/bin/odoo --config /etc/odoo/odoo.conf --logfile /var/log/odoo/odoo-server.log
Sep 20 11:22:35 debian11 systemd[1]: Started Odoo Open Source ERP and CRM.
Sep 20 11:22:37 debian11 odoo[11356]: Warn: Can't find .pfb for face 'Times-Roman'
默认情况下,Odoo14 正在侦听端口 8069,您可以使用以下命令进行检查:
ss -tunelp | grep 8069
输出 :
tcp LISTEN 0 128 0.0.0.0:8069 0.0.0.0:* users:(("odoo",pid=11356,fd=4)) uid:108 ino:30453 sk:7 cgroup:/system.slice/odoo.service <->
将 Nginx 配置为反向代理。
接下来,您需要将 Nginx 配置为 Odoo14 的反向代理。为此,请使用以下命令安装 Nginx 服务器:
apt-get install nginx -y
安装Nginx后,使用以下命令为Nginx虚拟主机创建配置文件:
nano /etc/nginx/conf.d/odoo14.conf
添加以下行:
upstream odoo14 {
server 127.0.0.1:8069;
}
server {
listen 80;
server_name odoo14.example.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://odoo14;
}
# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo14;
}
# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
保存并关闭文件并使用以下命令检查 Nginx:
nginx -t
输出 :
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
最后,重新启动 Nginx 服务以应用配置更改:
systemctl restart nginx
您可以使用以下命令检查 Nginx 的状态:
systemctl status nginx
输出 :
? nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-09-20 11:28:04 UTC; 6s ago
Docs: man:nginx(8)
Process: 11857 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 11858 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 11860 (nginx)
Tasks: 3 (limit: 4679)
Memory: 3.2M
CPU: 45ms
CGroup: /system.slice/nginx.service
??11860 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
??11861 nginx: worker process
??11862 nginx: worker process
Sep 20 11:28:04 debian11 systemd[1]: Starting A high performance web server and a reverse proxy server...
Sep 20 11:28:04 debian11 systemd[1]: Started A high performance web server and a reverse proxy server.
接下来,您需要编辑 Odoo14 配置文件并启用代理模式。
nano /etc/odoo/odoo.conf
添加以下行:
proxy_mode = True
保存并关闭文件并重新启动 Odoo14 服务以应用更改:
systemctl restart odoo
访问 Odoo14 网络界面
现在打开您的网络浏览器并使用 URL http://odoo14.example.com 访问 Odoo14 网络界面。您将被重定向到以下页面:
输入您的数据库、电子邮件地址和密码,然后单击创建数据库按钮。在下一页上,您应该看到 Odoo14 仪表板:
在 Odoo14 上启用 Let's Encrypt SSL。
建议使用 Let's Encrypt SSL 保护您的 Odoo14。首先使用以下命令安装 Certbot 客户端:
apt-get install python3-certbot-nginx -y
安装后,通过运行以下命令使用 Let's Encrypt SSL 保护您的网站:
certbot --nginx -d odoo14.example.com
您将被要求提供有效的电子邮件地址并接受使用条款(见下文):
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for odoo14.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/odoo14.conf
接下来,选择是否将 HTTP 流量重定向到 HTTPS(见下文):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
输入 2 并按 Enter 键完成安装。您应该看到以下输出:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/odoo14.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://odoo14.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=odoo14.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/odoo14.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/odoo14.example.com/privkey.pem
Your cert will expire on 2021-05-20. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot 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
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.
结论
在本教程中,您学习了如何在 Debian 11 上安装 Odoo14,并使用 Nginx 作为反向代理。您还学习了如何在 Odoo14 中启用 SSL 支持。如果您有任何疑问,请随时与我联系。