第一步:安装环境
1.1 安装Python3.6
# yum -y update
# yum -y groupinstall "Development tools"
# yum install glibc-static libstdc++-static
# yum install python36-devel libxslt-devel libxml2-devel openldap-devel
# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
# mkdir /usr/local/python3
# tar -xvJf Python-3.6.6.tar.xz
(包从Python官网下载https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz)
# cd Python-3.6.6
# ./configure --prefix=/usr/local/python3
# make && make install
# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# pip3 install --upgrade pip
# pip3 install --upgrade setuptools
# cd (返回根目录)
1.2 安装Sass
# pip3 install libsass (安装依赖库,若已安装无需执行)
# yum install sassc
1.3 安装wkhtmltopdf
# yum install libXrender xorg-x11-fonts-75dpi xorg-x11-fonts-Type1 libXext libjpeg libpng
(若已安装了则无需再安装)
# rpm -ivh wkhtmltox-0.12.5-1.centos7.x86_64.rpm
(GitHub中https://github.com/wkhtmltopdf/wkhtmltopdf/releases下载在根目录即可)
1.4 安装字体
# yum install wqy*
1.5 安装Postgresql数据库(Odoo12一定要PGSQL10,否则安装数据库的时候会出错)
# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
# yum install postgresql10
# yum install postgresql10-server
# /usr/pgsql-10/bin/postgresql-10-setup initdb
# systemctl enable postgresql-10
# systemctl start postgresql-10
# su - postgres -c "createuser -s odoo"
第二步: 解压程序,安装Python组件及运行Odoo
1.1 创建odoo用户及odoo用户组
# groupadd odoo
# adduser -g odoo -d /home/wwwroot/www.domain.com -m odoo (查看是否有/home/wwwroot文件夹,若没有则新增)
# passwd odoo
# *** (后面安装和登陆均会用到,请牢记!)
1.2 授予odoo sudo权限
# vi /etc/sudoers
修改文件参考如下:
## Allow root to run any commands anywhere
root ALL=(ALL:ALL) ALL
odoo ALL=(ALL:ALL) ALL (增加部分)
保存退出,odoo用户就拥有了sudo权限。
# reboot
1.3 用odoo用户登陆SSH和WinSCP(SFTP)
1.4 下载最新的程序包(默认登陆SSH在/home/odoo下面)
# wget http://nightly.odoo.com/12.0/nightly/src/odoo_12.0.latest.tar.gz
# tar –zxvf odoo_12.0.latest.tar.gz
1.5 在WinSCP里面将odoo-12.post2018****文件夹的内容全部(含隐藏文件)copy到www.domain.com里面
# cp -R /home/wwwroot/odoo-12.post2018****/. /home/wwwroot/www.domain.com
1.6 用SSH安装 Odoo所需的Python3组件.
# cd ./www.domain.com
# sudo pip3 install -r requirements.txt
(根据git版的提示,建议在执行命令前在最后2行插入:
sphinx>=1.2
sphinx-patchqueue>=1.0)
1.7 进入odoo源码目录(/home/wwwroot/www.domain.com)运行odoo-bin (没有可以自行创建,并给与755权限, 内容可参考github里的对应文件)并生成配置文件.
(备注,由于未改动原python2.X,因此需要修改odoo-bin第1行 #!/usr/bin/env python3为 #!/usr/bin/python3)
# ./odoo-bin -s
1.8 设置配置文件
# sudo mkdir /etc/odoo
# sudo cp /home/wwwroot/www.domain.com/.odoorc /etc/odoo/odoo.conf
# sudo chown -R odoo:odoo /etc/odoo
# sudo mkdir /var/log/odoo
# sudo chown -R odoo:odoo /var/log/odoo
1.9 编辑配置文件
# sudo vi /etc/odoo/odoo.conf
下面是2个建议增加的值 :
[options]
logfile = /var/log/odoo/odoo.log
logrotate = True
1.10 创建开机启动odoo
# sudo vi /lib/systemd/system/odoo.service
内容如下:
[Unit]
Description=Odoo
After=postgresql-10.service
[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/home/wwwroot/www.domain.com/odoo-bin -c /etc/odoo/odoo.conf
[Install]
WantedBy=multi-user.target
注册新的服务:
# sudo systemctl enable odoo.service
开启这个新服务:
# sudo systemctl start odoo
检查它的状态:
# sudo systemctl status odoo
重启这个服务:
# sudo systemctl restart odoo
若显示如下内容则表示运行成功了:
● odoo.service - Odoo
Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2018-10-10 10:46:54 CST; 6s ago
Main PID: 930 (python3)
CGroup: /system.slice/odoo.service
└─930 python3 /home/wwwroot/www.domain.com/odoo-bin -c /etc/odoo/odoo.conf
如果您希望停止它,使用下面的命令:
# sudo systemctl stop odoo
也可以用 service odoo start 和 service odoo stop 来开启停止服务。
现在可以确认我们的Odoo实例启动了,并能响应请求。
如果Odoo正常运行,我们可以在日志文件中获得信息。我们可以检查Odoo是否响应HTTP请求:
# curl http://localhost:8069
要检查日志文件,我们可以使用:
# sudo less /var/log/odoo/odoo.log (Q键退出)
您还可以使用tail -f:
# sudo tail -f /var/log/odoo/odoo.log (Ctrl+C退出)
1.11 登录IP:8069, 按照提示安装数据库即可正常运行odoo
1.12 安装好niginx并设置好vhost(建议用oneinstack的openresty)后, 将/usr/local/openresty/nginx/conf/vhost/www.domain.com备份,然后用下面的代码更换后重启服务器即可用域名访问(建议https).
Nginx代码如下:
upstream odoo12 {
server 127.0.0.1:8069 weight=1 fail_timeout=0;
}
upstream odoo12-im {
server 127.0.0.1:8072 weight=1 fail_timeout=0;
}
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /usr/local/openresty/nginx/conf/ssl/www.domain.com.crt;
ssl_certificate_key /usr/local/openresty/nginx/conf/ssl/www.domain.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name www.domain.com domain.com;
access_log /home/wwwlogs/www.domain.com_nginx.log combined;
error_log /home/wwwlogs/www.domain.com_nginx_err.log notice;
index index.html index.htm index.php;
root /home/wwwroot/www.domain.com;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }
if ($host != www.domain.com) { return 301 $scheme://www.domain.com$request_uri; }
include /usr/local/openresty/nginx/conf/rewrite/none.conf;
#error_page 404 /404.html;
#error_page 502 /502.html;
#increase proxy buffer to handle some OpenERP web requests
proxy_buffers 16 64k;
proxy_buffer_size 128k;
#general proxy settings
#force timeouts if the backend dies
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
#set headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
#Let the OpenERP web service know that we’re using HTTPS, otherwise
#it will generate URL using http:// and not https://
proxy_set_header X-Forwarded-Proto https;
#by default, do not forward anything
proxy_redirect off;
proxy_buffering off;
location / {
proxy_pass http://odoo12;
}
location /longpolling {
proxy_pass http://odoo12-im;
}
#cache some static data in memory for 60mins.
#under heavy load this should relieve stress on the OpenERP web interface a bit.
location /web/static/ {
proxy_cache_valid 200 60m;
proxy_buffering on;
expires 864000;
proxy_pass http://odoo12;
}
}
备注: 已根据1楼的朋友更新教程, 欢迎大家随时交流, 我的QQ:65016198. 谢谢.