跳至内容

CentOS快速部署Odoo12

系统版本:CentOS 7.2


换源:(已换源或已设置可跳过此步)

    备份一下镜像文件

        mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

    下载阿里云源

        wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

    运行命令生成缓存

        yum clean all

        yum makecache


开始部署:

    更新下载源

        yum update

    安装EPEL存储库

        yum install epel-release

    安装python和odoo依赖项

        yum install centos-release-scl

        yum install rh-python36

        如果安装rh-python36报错,安装 Software Collections 源:yum install centos-release-scl

        yum install git gcc wget nodejs-less libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel

    创建odoo服务运行用户和和组

        useradd -m -U -r -d /opt/odoo -s /bin/bash odoo

    安装数据库PostgreSQL

        yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm -y

        yum install postgresql96 postgresql96-server postgresql96-contrib postgresql96-libs -y

    初始化数据库

        /usr/pgsql-9.6/bin/postgresql96-setup initdb

    配置数据库服务

        systemctl start postgresql-9.6.service

        systemctl enable postgresql-9.6.service

    创建一个PostgreSQL用户

        su - postgres -c "createuser -s odoo"

    安装Wkhtmltopdf

        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

    安装配置odoo12(若想安装其他版本自行更改)

        su - odoo

        git clone https://www.github.com/odoo/odoo --depth 1 --branch 12.0 /opt/odoo/odoo12

    用软件集合访问python3.6

        scl enable rh-python36 bash

    创建虚拟环境

        cd /opt/odoo

        python3 -m venv odoo12-venv

    激活虚拟环境

        source odoo12-venv/bin/activate

    升级pip并安装wheel

        pip install --upgrade pip

        pip3 install wheel

    安装odoo用到的python库

        pip3 install -r odoo12/requirements.txt

    退出虚拟环境至root用户

        deactivate && exit

        exit

    创建自定义模块目录(也可其他位置、其他文件名)

        mkdir /opt/odoo/odoo12-custom-addons

        chown odoo: /opt/odoo/odoo12-custom-addons

    创建odoo配置文件

        vim /etc/odoo.conf

    下文粘贴至配置文件中

        [options]

        ; This is the password that allows database operations:

        admin_passwd = master_password

        db_host = False

        db_port = False

        db_user = odoo

        db_password = False

        addons_path = /opt/odoo/odoo12/addons

        ; You can enable log file with uncommenting the next line

        ; logfile = /var/log/odoo12/odoo.log

        ; If you are using custom modules

        ; addons_path = /opt/odoo/odoo12/addons,/opt/odoo/odoo12-custom-addons

    创建odoo服务

        vim /etc/systemd/system/odoo12.service

    下文粘贴至创建文件中

        [Unit]

        Description=Odoo12

        Requires=postgresql-9.6.service

        After=network.target postgresql-9.6.service

 

        [Service]

        Type=simple

        SyslogIdentifier=odoo12

        PermissionsStartOnly=true

        User=odoo

        Group=odoo

        ExecStart=/usr/bin/scl enable rh-python36 -- /opt/odoo/odoo12-venv/bin/python3 /opt/odoo/odoo12/odoo-bin -c /etc/odoo.conf

        StandardOutput=journal+console

        [Install]

        WantedBy=multi-user.target

     重新加载服务程序

        systemctl daemon-reload

    启动odoo服务

        systemctl start odoo12

    查看odoo服务状态(如显示Active为running则表示成功)

        systemctl status odoo12

    设置自启动odoo服务

        systemctl enable odoo12

    测试结果

        打开浏览器(要知道服务器的IP)

        http://ip:8069或本地打开:http://127.0.0.1:8069

 

odoo前后端交互