一、更换阿里源
1、备份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2、添加阿里源
sudo vim /etc/apt/sources.list
# 添加在文件最前面
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
3、更换Python的pip源
在主目录下创建.pip文件夹,然后在该目录下创建pip.conf文件
mkdir ~/.pip
vim ~/.pip/pip.conf
pip.conf文件编写如下内容保存(更换为阿里源):
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com
4、更新系统
sudo apt update && sudo apt upgrade -y
若出现”Release 404 Not Found [IP: 221.130.253.135 8080]N: 无法安全地用该源进行更新,所以默认禁用该源。“的报错则进入到Ubuntu 18.04系统的/etc/apt/sources.lisd.d目录中根据上面的错误提示(没有Release文件)删除对应的文件或目录,如果没有名字相同的要用记事本一一打开查找该源并删除。
二、安装 Python 3并配置环境变量 (odoo13需3.6及以上版本)
sudo apt install git python3 python3-pip build-essential wget python3-dev python3-wheel libxslt1-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools -y(安装依赖前必须装这个不然会报错)
echo alias python=python3 >> ~/.bashrc
source ~/.bashrc
三、添加libpng12-0存储库,wkhtmltopdf将使用此依赖
sudo add-apt-repository universe
sudo add-apt-repository "deb http://mirrors.aliyun.com/ubuntu/ xenial main"
sudo apt update && sudo apt upgrade -y
下载安装wkhtmltopdf(建议提前下载好)
# wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.trusty_amd64.deb
# sudo dpkg -i wkhtmltox_0.12.5-1.trusty_amd64.deb
# sudo apt --fix-broken install -y
# 进入文件下载路径解压
# sudo apt-get install gdebi
sudo gdebi wkhtmltox_0.12.5-1.trusty_amd64.deb
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
四、安装中文字体
sudo apt install fonts-wqy-zenhei fonts-wqy-microhei -y
五、安装依赖包
在requirements.txt路径下打开终端:
pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
# sudo pip3 install -r https://github.com/odoo/odoo/raw/13.0/requirements.txt# sudo pip3 install -r https://github.com/odoo/odoo/raw/12.0/requirements.txt# 因源码包里面一般都有requirements.txt,因此一般直接pip3 install -r requirements.txt安装即可,无需用网络地址安装。
如果启动Werkzeug报错
pip uninstall Werkzeug
pip install Werkzeug==0.11.15
sudo apt-get install libpq-dev
pip install psycopg2
六、安装Postgresql12
1、安装
sudo apt-get install postgresql-12
2、检查 PostgreSQL 是否正在运行
service postgresql status
3、登录账户:
sudo su postgres
psql
4、修改密码
ALTER USER postgres WITH PASSWORD 'my_password';
5、创建用户
CREATE USER my_user WITH PASSWORD 'my_password';
6、赋予权限
ALTER USER my_user WITH SUPERUSER;
7、删除用户
DROP USER my_user;
8、创建用户
CREATE ROLE odoo WITH LOGIN SUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD '123456';
9、查看用户
\du
10、退出
\q
11、开启远程连接
sudo vim /etc/postgresql/10/main/postgresql.conf
listen_addresses = '*'(# listen_addresses = '*'前添加,60行)
sudo vim /etc/postgresql/10/main/pg_hba.conf
host all all 0.0.0.0/0 md5(# IPv4 local connections后添加,96行)
12、重启数据库
sudo service postgresql restart
七、安装Odoo13
克隆代码(可选,也可在Odoo Nightly builds下载源码包或使用已有源码包解压,假设解压路径为/opt)
# git clone https://www.github.com/odoo/odoo --depth 1 -b 13.0
# git clone https://gitee.com/mirrors/odoo -b 13.0 --depth=1
# git clone https://www.github.com/odoo/odoo --depth 1 -b 12.0
# pip3 install phonenumbers # 可选
进入文件下载路径解压(建议)
#sudo tar -xvf odoo_13.0.latest.tar.gz -C /opt/
unzip odoo_13.0.20200824.zip
# 改名
mv odoo-13.0.post20200824/ odoo13
# 复制出odoo-bin
cp setup/odoo odoo-bin
#创建执行权限文件(可选)
sudo chmod +x odoo-bin
八、创建并编辑Odoo配置文件
sudo vim /etc/odoo.conf
[options]
; This is the password that allows database operations:
; admin_passwd = admin
; xmlrpc_port = 8888
db_host = False
db_port = 5433
db_user = odoo
db_password = odoo
addons_path = /opt/odoo/odoo/addons
九、启动Odoo
python3 /odoo13/odoo-bin -c /etc/odoo.conf &(加上此符号当关闭cmd时服务不会关闭)
python3 /home/vwpt/odoo13/odoo-bin -c /home/vwpt/odoo.conf
十、防火墙开放端口
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
内网可直接关闭防火墙
sudo ufw disable
查看防火墙当前状态
sudo ufw status