前提
OS:Ubuntu 20.04LTS
Odoo:14旗舰版
数据库:Postgres13.0
*数据库和Odoo安装在一台服务器
系统设置
- 为了Log日志时间好看,进行系统时区设置
# 查看可用时区
timedatectl list-timezones
# 设置本地时区
sudo timedatectl set-timezone Asia/Singapore
# 查看效果
timedatectl
# 重启服务
sudo reboot
- 安装数据库Postgres
- 参考官网教程
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-13
# 默认会使用系统时区
- 查看安装结果
# 查看服务启动情况
service postgresql status
# 查看监听端口
ss -nlt | grep 5432
- 添加数据库的Odoo用户
# 创建用户:odoo
sudo -u postgres createuser -s -i -d -r -l -w odoo
# 设置密码:odoo
sudo -u postgres psql -c "ALTER ROLE odoo WITH PASSWORD 'odoo';"
# 测试是否可以链接
psql -h 127.0.0.1 -U odoo -d postgres
# 进入后查看odoo用户权限(必须有创建数据库权限initdb)
\du
- 配置数据库
sudo vi /etc/postgresql/13/main/postgresql.conf
# 日志保存天数设置
log_rotation_age = 7d
# 时区确认
log_timezone = 'Asia/Singapore'
timezone = 'Asia/Singapore'
- 安装Nginx
- 参考官网教程
deb https://nginx.org/packages/ubuntu/ focal nginx
deb-src https://nginx.org/packages/ubuntu/ focal nginx
sudo apt update
sudo apt install nginx
# 查看服务
sudo systemctl status nginx
- 安装Odoo
- 安装PDF账票出力包,下载地址
sudo apt-get install -y --no-install-recommends ./wkhtmltox.deb
sudo rm -rf /var/lib/apt/lists/* wkhtmltox.deb
- 安装pip和其他pip包
sudo apt-get install -y --no-install-recommends \
ca-certificates \
curl \
dirmngr \
fonts-roboto \
gnupg \
libssl-dev \
node-less \
npm \
python3-num2words \
python3-pdfminer \
python3-pip \
python3-phonenumbers \
python3-pyldap \
python3-qrcode \
python3-renderpm \
python3-setuptools \
python3-slugify \
python3-vobject \
python3-watchdog \
python3-xlrd \
python3-xlwt \
xz-utils
sudo pip install --upgrade pip
# 不更新二维码生成或者图片上传会失败
sudo pip install reportlab --upgrade
# 前台渲染用
sudo npm install -g less
- 下载旗舰版安装包,如果有PartnerCode就带在链接后面:https://www.odoo.com/page/download?code=xxxxxx
- 下载包放入服务器,参考官网教程安装
# 进入root权限
sudo su
# 尝试安装,如果失败进行apt包安装
dpkg -i odoo_e22222.deb
# 上面失败后,执行这步会安装相关包
apt-get install -f
# 再次安装
dpkg -i odoo_e22222.deb
- 配置Odoo
sudo vi /etc/odoo/odoo.conf
# 设置自己开发插件位置
addons_path = /mnt/addons
# 设置前端后台操作密码
admin_passwd = xxxxx
# 设置Session等静态文件保存路径
data_dir = /var/lib/odoo
# 设置数据库链接
db_host = localhost
db_maxconn = 64
db_name = False
db_password = odoo
db_port = 5432
db_template = template1
db_user = odoo
# 超时时间设置
limit_time_cpu = 360
limit_time_real = 720
limit_time_real_cron = -1
# 是否显示DB列表(生产环境建议关闭)
list_db = True
# log配置
log_db = False
log_db_level = warning
log_handler = :INFO
log_level = debug_rpc
logrotate = True
# 多worker会使用
longpolling_port = 8072
# 后台自动处理同时执行个数
max_cron_threads = 3
# 是否有代理
proxy_mode = False
# 启动服务时候初期化模块
server_wide_modules = base,web,web_kanban_gauge
# 测试配置
test_commit = False
test_enable = False
test_file = False
test_report_directory = False
translate_modules = ['all']
unaccent = False
# 不加载测试数据
without_demo = False
# 多线程使用。计算方式:服务器cpu 内核数*2- 自动处理个数
workers = 4
# API链接设置,参考另一篇
xmlrpc = True
xmlrpc_interface =
xmlrpc_port = 8069
- Log保存期限设置
# 系统日志配置
sudo vi /etc/logrotate.d/rsyslog
# Nginx日志配置
sudo vi /etc/logrotate.d/nginx
# Odoo日志配置
sudo vi /etc/logrotate.d/odoo
# Postgres日志配置
sudo vi /etc/logrotate.d/postgresql-common
- 设置内容如下
# 修改保存期
rotate 14
# 修改保存格式
dateext
dateformat _%Y-%m-%d
- Nginx设置
- 参考Odoo例子配置,主要转发到8069和8072端口
#odoo server
upstream odoo {
server 127.0.0.1:8069;
}
upstream odoochat {
server 127.0.0.1:8072;
}
# http -> https
server {
listen 80;
server_name odoo.mycompany.com;
rewrite ^(.*) https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name odoo.mycompany.com;
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
# Add Headers for odoo proxy mode
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;
# SSL parameters
ssl_certificate /etc/ssl/nginx/server.crt;
ssl_certificate_key /etc/ssl/nginx/server.key;
ssl_session_timeout 30m;
ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;
# log
access_log /var/log/nginx/odoo.access.log;
error_log /var/log/nginx/odoo.error.log;
# Redirect longpoll requests to odoo longpolling port
location /longpolling {
proxy_pass http://odoochat;
}
# Redirect requests to odoo backend server
location / {
proxy_redirect off;
proxy_pass http://odoo;
}
# common gzip
gzip_types text/css text/scss text/plain text/xml application/xml application/json application/javascript;
gzip on;
}
每天成就一小步,积累下来就是一大步。
转发本文请注明出处,谢谢您的阅读与分享!