如何在CentOS 7上安装Odoo 13
本指南将引导我们完成在CentOS 7上安装和配置Odoo 13的步骤。Odoo是一种流行的商业软件,具有一系列的商业应用程序,例如CRM,POS,构建器,仓库管理,项目管理,电子商务,市场营销,计费。与会计,制造业等等。所有这些应用程序都无缝集成,并通过一个Web控制台进行管理。
在撰写本文时,可下载和使用的Odoo的最新版本是Odoo v13. 在本文的其余部分中,我们将在CentOS 7上安装和配置Odoo13. 使用PostgreSQL数据库和Nginx作为在CentOS 7上运行的Odoo 13的前端代理。
添加EPEL存储库
通过运行命令将EPEL存储库添加到CentOS 7.
sudo yum -y install epel-release vim bash-completion
将SELinux置于宽松模式。
sudo setenforce 0 sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config
添加EPEL存储库后,建议我们更新系统。
sudo yum -y update
安装PostgreSQL数据库服务器
添加EPEL存储库后,在CentOS 7上安装PostgreSQL数据库服务器。撰写本文时,最新版本的PostgreSQL是版本12. 请使用我们的指南进行安装。
如何在CentOS 7上安装PostgreSQL 12
安装wkhtmltopdf
Odoo使用wkhtmltopdf生成PDF格式的报告。推荐安装的wkhtmltopdf版本为0.12.5,可从wkhtmltopdf下载页面的"存档"部分获得。
sudo yum install -y https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
确认安装的版本。
$wkhtmltopdf --version wkhtmltopdf 0.12.5 (with patched qt)
在CentOS 7上安装Odoo 13
现在让我们开始在CentOS 7上安装Odoo 13,首先将Odoo Yum存储库添加到我们的系统中。
sudo yum -y install yum-utils sudo yum-config-manager --add-repo=http://nightly.odoo.com/13.0/nightly/rpm/odoo.repo
存储库文件将添加到/etc/yum.repos.d/odoo.repo。
更新软件包索引并在CentOS 7上安装Odoo 13.
sudo yum makecache fast sudo yum install odoo
从我们之前添加的Base和EPEL存储库中安装了许多依赖程序包。按y键开始在CentOS 7上安装Odoo 13.
收到提示时,请接受GPG密钥的导入。
Retrieving key from https://nightly.odoo.com/odoo.key Importing GPG key 0x8183CBB5: Userid : "Odoo SA, Linux Package Signing Key <theitroad@localhost>" Fingerprint: 5d13 4c92 4cb0 6330 dcef e2a1 def2 a219 8183 cbb5 From : https://nightly.odoo.com/odoo.key Is this ok [y/N]: y
一个odoo systemd服务已创建但未启动。让我们启动它,并将其设置为启动和启动时间。
sudo systemctl enable --now odoo
确认Odoo服务是否设置为在启动时启动。
$systemctl is-enabled odoo enabled
检查是否正在运行。
$systemctl status odoo ● odoo.service - Odoo Open Source ERP and CRM Loaded: loaded (/usr/lib/systemd/system/odoo.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2019-10-21 10:38:53 UTC; 1min 22s ago Main PID: 15559 (odoo) CGroup: /system.slice/odoo.service └─15559 /usr/bin/python /usr/bin/odoo --config /etc/odoo/odoo.conf --logfile /var/log/odoo/odoo-server.log Oct 21 10:38:53 cent7.novalocal systemd[1]: Started Odoo Open Source ERP and CRM.
一旦启动,Odoo服务应绑定到TCP端口8069.
$ss -tunelp | grep 8069 tcp LISTEN 0 128 *:8069 *:* uid:997 ino:67021 sk:ffff911b7549ae80 <->
配置Nginx代理(不使用SSL)不推荐
在CentOS 7上安装Nginx
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.theitroad.local; 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.theitroad替换为域名,然后验证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
配置Nginx代理(使用SSL证书)推荐
如果服务器具有公共IP,则可以为域创建DNS A记录以指向Odoo Server并请求免费的Lets Encrypt SSL证书。
在CentOS 7上安装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.theitroad.local" export EMAIL="theitroad@localhost" 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.theitroad.local/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/erp.theitroad.local/privkey.pem Your cert will expire on 2017-01-19. 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" - 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.theitroad.local; return 301 https://erp.theitroad.local$request_uri; } server { listen 443 ssl; server_name erp.theitroad.local; access_log /var/log/nginx/odoo_access.log; error_log /var/log/nginx/odoo_error.log; # SSL ssl_certificate /etc/letsencrypt/live/erp.theitroad.local/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/erp.theitroad.local/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/erp.theitroad.local/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
在Debian 10 Linux上访问Odoo
从Web https://DNShostname访问我们域名上的Odoo网页。
在第一页上,设置数据库名称,管理员用户的电子邮件地址和管理员用户的密码。
使用"应用程序"菜单安装其他Odoo应用程序。