How to deploy Odoo 11 on Ubuntu 18.04

参考这篇

Before you begin

Update the system to the latest packages:

sudo apt update && sudo apt upgrade

Install gitpip and all other tools and libraries required to build Odoo dependencies:

sudo apt install git python3-pip build-essential wget python3-dev python3-venv python3-wheel libxslt-dev libzip-dev libldap2-dev libsasl2-dev python3-setuptools node-less

Create Odoo user

Create a new system user and group with home directory /opt/odoo that will run the Odoo service.

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

Install and configure PostgreSQL

Install the Postgres package from the Ubuntu’s default repositories:

sudo apt-get install postgresql

Once the installation is completed create a postgres user with the same name as the previously created system user, in our case odoo:

sudo su - postgres -c "createuser -s odoo"

Install and configure Odoo

We will install odoo from the GitHub repository inside an isolated Python environment so we can have more control over versions and updates.

Before starting with the installation process, make sure you switch to odoo user.

sudo su - odoo

To confirm that you are logged-in as odoo user you can use the following command:

whoami

Now we can start with the installation process, first clone the odoo from the GitHub repository:

git clone https://www.github.com/odoo/odoo --depth 1 --branch 11.0 /opt/odoo/odoo11

To create a new virtual environment for our Odoo 11 installation run:

cd /opt/odoo
python3 -m venv odoo11-venv

activate the environment with the following command:

source odoo11-venv/bin/activate

and install all required Python modules with pip3:

pip3 install wheel
pip3 install -r odoo11/requirements.txt

Once the installation is completed deactivate the environment and switch back to your sudo user using the following commands:

deactivate
exit

If you plan to install custom modules it is best to install those modules in a separate directory. To create a new directory for our custom modules run:

sudo mkdir /opt/odoo/odoo11-custom-addons
sudo chown odoo: /opt/odoo/odoo11-custom-addons

Next, we need to create a configuration file, we can either create a new one from scratch or copy the included configuration file:

sudo cp /opt/odoo/odoo11/debian/odoo.conf /etc/odoo11.conf

Open the file and edit it as follows:

/etc/odoo11.conf
[options]
; This is the password that allows database operations:
admin_passwd = my_admin_passwd
db_host = False
db_port = False
db_user = odoo
db_password = False
addons_path = /opt/odoo/odoo11/addons
; If you are using custom modules
; addons_path = /opt/odoo/odoo11/addons,/opt/odoo/odoo11-custom-addons

Create a systemd unit file

To run odoo as a service we will create a odoo11.service unit file in the /etc/systemd/system/directory with the following contents:

/etc/systemd/system/odoo11.service
[Unit]
Description=Odoo11
Requires=postgresql.service
After=network.target postgresql.service

[Service]
Type=simple
SyslogIdentifier=odoo11
PermissionsStartOnly=true
User=odoo
Group=odoo
ExecStart=/opt/odoo/odoo11-venv/bin/python3 /opt/odoo/odoo11/odoo-bin -c /etc/odoo11.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Notify systemd that we created a new unit file and start the Odoo service by executing:

sudo systemctl daemon-reload
sudo systemctl start odoo11

You can check the service status with the the following command:

sudo systemctl status odoo11

and if there are no errors you can enable the Odoo service to be automatically started at boot time:

sudo systemctl enable odoo11

If you want to see the messages logged by the Odoo service you can use the command below:

sudo journalctl -u odoo11

Test the Installation

Open your browser and type: http://<your_domain_or_IP_address>:8069

Assuming that installation is successful, a screen similar to the following will appear:

 
 

猜你喜欢

转载自www.cnblogs.com/lnkDel/p/9475470.html