odoo13线上发布
环境
centos7.3
python3.7.0
postgresql10
odoo13
CentOS 7系统的升级
运行以下命令更新服务器:
yum update
更新服务器后,输入以下内容启用EPEL 资源库 :
yum install epel-release
Python3.7的安装
需要切换到root
用户:
sudo root
安装相关编译工具
yum -y groupinstall "Development tools"
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
yum install libffi-devel -y
下载并解压安装包
cd /opt # 待安装的目录
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar -xvJf Python-3.7.0.tar.xz
创建编译安装的目录
mkdir /usr/local/python3
编译并安装
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
创建相关的软链接
ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
验证python和pip的版本
python3 -V
pip3 -V
会得到以下结果:
Python 3.7.0
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)
odoo相关依赖的安装
yum install git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel
创建Odoo的用户
创建一个用于运行Odoo名为oodo13的系统用户,主目录为/opt/odoo13:
sudo useradd -m -d /opt/odoo13 -U -r -s /bin/bash odoo13
*注:
这里可以随意命名用户,但不要忘记创建一个具有相同名称的PostgreSQL用户。
安装和配置PostgreSQL
参考链接
https://www.cnblogs.com/zhi-leaf/p/11432054.html
1、安装rpm文件
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
2、安装客户端
yum install postgresql10
3、安装服务端
yum install postgresql10-server
和其他
yum install postgresql10-contrib postgresql10-libs -y
4、初始化
/usr/pgsql-10/bin/postgresql-10-setup initdb
5、设置自动启动并且启动postgresql服务
systemctl enable postgresql-10
systemctl start postgresql-10
6.最后,创建一个PostgreSQL用户,需要和已经为Odoo创建的用户(本例中用户名为odoo13)使用相同的名称。
sudo su - postgres -c "createuser -s odoo13"
Wkhtmltopdf的安装
wkhtmltopdf
软件包是Odoo用来将PDF
格式的HTML
制成以便可以打印PDF
报告的开源工具。 本案例中安装0.12.5版本,该版本在CentOS 7官方存储库中不可用。 为了下载并安装此版本,需要运行以下命令:
cd /opt/
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
yum localinstall wkhtmltox-0.12.5-1.centos7.x86_64.rpm
Odoo 13的安装与配置
首先,需要更改为用户“odoo13”:
su - odoo13
从Github的存储库中下载Odoo 13源代码:
git clone https://www.github.com/odoo/odoo --depth 1 --branch 13.0 /opt/odoo13/odoo
下载完成后,为Odoo创建一个新的Python
虚拟环境:
cd /opt/odoo13
python3 -m venv odoo13-venv
激活所创建的Python
虚拟环境:
source odoo-venv/bin/activate
升级pip、setuptools,并安装Wheel库:
pip install --upgrade pip
pip install --upgrade setuptools
pip3 install wheel
使用pip3
安装所有必需的Python模块:
pip3 install -r odoo/requirements.txt -i https://pypi.doubanio.com/simple
完成后,通过键入以下命令停用环境并退出:
deactivate && exit
我们将创建一个包含第三方插件新目录,并将该目录的所有者更改为odoo13:
mkdir /opt/odoo13/odoo13-custom-addons
chown odoo13: /opt/odoo13/odoo13-custom-addons
修改数据库连接的配置信息:
vi /var/lib/pgsql/9.6/data/pg_hba.conf
将数据库访问的配置信息修改如下:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
创建Odoo13的配置文件:
vi /etc/odoo13.conf
配置文件的内容如下:
[options]
; This is the password that allows database operations:
admin_passwd = admin_password
db_host = False
db_port = False
db_user = odoo13
db_password = False
addons_path = /opt/odoo13/odoo/addons,/opt/odoo13/odoo13-custom-addons
*注:
- 请记得使用自己的密码更换
admin_password
的内容。
创建系统单元文件并测试安装
创建一个名为odoo13.service
的服务单元文件:
sudo vi /etc/systemd/system/odoo13.service
系统单元文件的内容如下:
[Unit]
Description=Odoo13
Requires=postgresql-10.service
After=network.target postgresql-10.service
[Service]
Type=simple
SyslogIdentifier=odoo13
PermissionsStartOnly=true
User=odoo13
Group=odoo13
ExecStart=/opt/odoo13/odoo13-venv/bin/python3 /opt/odoo13/odoo/odoo-bin -c /etc/odoo13.conf
StandardOutput=journal+console
[Install]
WantedBy=multi-user.target
然后重新加载守护程序,使之在systemd
中创建的新单元:
systemctl daemon-reload
可以启动Odoo13的服务:
systemctl start odoo13
可以查看Odoo13的服务状态:
systemctl status odoo13
得到启动的状态如下
● odoo13.service - Odoo13
Loaded: loaded (/etc/systemd/system/odoo13.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-11-19 15:21:40 CST; 2h 20min ago
Main PID: 28867 (python3)
CGroup: /system.slice/odoo13.service
└─28867 /opt/odoo13/odoo13-venv/bin/python3 /opt/odoo13/odoo/odoo-bin -c /etc/odoo13.conf
如果没有出现错误,可以使用以下命令启用Odoo13的服务开机自启:
systemctl enable odoo13
要查看Odoo日志的消息,可以使用以下命令:
journalctl -u odoo13
开启数据库远程访问
进入修改文件目录:
cd /var/lib/pgsql/10/data/
编译配置文件:
vi pg_hba.conf
修改文件末尾处 # IPv4 local connections
的内容:
host all all 127.0.0.1/32 ident # 在本行下面添加
host all all 0.0.0.0/0 trust # 添加内容
编译配置文件:
vi postgresql.conf
修改Connection Settings
为以下内容:
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
输入以下指令进入数据库:
sudo su – postgres
进入数据库后,输入以下指令:
-bash-4.2$ psql
psql (9.6.12)
Type "help" for help.
修改“odoo13”用户的初始密码:
postgres=# alter user odoo with password 'odoo';
修改密码后,退出数据库:
postgres=# \q
-bash-4.2$ exit
Logout
测试
ip:8069
nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on; #开启gzip,加快oe首页的加载速度。
gzip_min_length 1024;
gzip_http_version 1.1;
gzip_comp_level 1;
gzip_types text/plain application/javascript application/x-javascript text/css
application/xml text/javascript/x-httpd-php image/jpeg image/gif image/png application/
vnd.ms-fontobject font/ttf font/opentype font/x-woff image/svg+xml;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
gzip_buffers 32 4K;
server {
listen 80; #监听80端口
server_name 116.62.152.65;
location / {
proxy_pass http://116.62.152.65:8069; #反向代理服务器的ip:端口
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /nginx-status {
stub_status on;
access_log off;
allow 127.0.0.1;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
可能出现bug
Loaded plugins: fastestmirror
yum install的时候提示:Loaded plugins: fastestmirror
fastestmirror是yum的一个加速插件,这里是插件提示信息是插件不能用了。
不能用就先别用呗,禁用掉,先yum了再说。
1.修改插件的配置文件
# vi /etc/yum/pluginconf.d/fastestmirror.conf
enabled = 1//由1改为0,禁用该插件
2.修改yum的配置文件
# vi /etc/yum.conf
plugins=1//改为0,不使用插件
nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)
[root@TEST nginx]# sudo nginx -c /etc/nginx/nginx.conf
[root@TEST nginx]# nginx -s reload
linux-postgresql资源404
https://www.cnblogs.com/zhi-leaf/p/11432054.html
参考链接
https://www.jianshu.com/p/ae6b7f8feb9c
https://www.cnblogs.com/zhi-leaf/p/11432054.html
主要参考以上链接,但是会有问题,这是我成功运行起来的步骤
nginx
https://blog.csdn.net/weixin_42167759/article/details/85049546
https://blog.csdn.net/qq_36178641/article/details/80167870