Install Odoo11 from source code
Organizing and testing: Odoo11 installation, Odoo11 production environment deployment: Install Odoo11 and configure it as a service under Ubuntu Server 16.04
This article uses a
sudo adduser
2: Grant root permission:
sudo vi /etc/sudoers
Modify the file as follows:
# User privilege specification
root ALL=(ALL:ALL) ALL
Save and exit,
Switch user:
Note: During testing, directly logged in remotely via Putty using the odoo user.
3: Enter odoo's home directory cd ~
Step 1: Update installation dependencies and clone the Odoo source code
1.1 Update System
sudo apt update #Note: Under 16.04, only need to enter "sudo apt update", -get can be omitted
sudo apt upgrade #There will be a prompt asking you to confirm whether to keep the current version
sudo apt install git # Note: 16.04.3 comes with git, no need to install
Note: After the update is complete, it is best to restart the server.
sudo reboot
1.2 Install nodejs (use the following command after 14.04):
sudo apt-get install -y npm
sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g less # Pay attention to the success prompt during installation
1.3 Clone the odoo source code. The following command will clone it into the odoo11 subdirectory:
git clone https://github.com/odoo/odoo.git odoo11 -b 11.0 --depth=1
Step 2: Install the dependencies required by the Odoo system:
2.1
sudo apt-get install -y python3-pip
sudo pip3 install Babel decorator docutils ebaysdk feedparser gevent greenlet html2text Jinja2 lxml Mako MarkupSafe mock num2words ofxparse passlib Pillow psutil psycogreen psycopg2 pydot pyparsing PyPDF2 pyserial python-dateutil python-openid pytz pyusb PyYAML qrcode reportlab requests six suds-jurko vatnumber vobject Werkzeug XlsxWriter xlwt xlrd
Note: When installing these dependencies, pay attention to the download speed, as it may be slow during certain time periods. Sometimes the server may also be inaccessible, so watch for the prompt after a successful installation. If it doesn't work, try installing at a different time, and you'll find it much faster (e.g., before 8 AM).
Prompt after successful installation: Successfully installed
2.2 Install PostgreSQL and database user:
sudo apt-get install -y postgresql
2.3 Create the odoo user in the database ():
sudo su - postgres
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
Enter password for new role: *****
Enter it again:*****
exit
Enter the odoo source code directory, run odoo, and generate a configuration file (you can also create a simple configuration file yourself)
cd ~/
From the startup log, it can be seen that a configuration file .odoorc will be generated in the current user's root directory (this configuration file will be used in the third step).
Using configuration file at /home/odoo/.odoorc
Open another terminal window and use ps aux |grep odoo to see the usage of odoo, for example:
odoo 1010 0.9 1.6 421168 66852 pts/0 Sl+ 12:22 0:00 python3 ./odoo-bin -c /etc/odoo/odoo.conf
It should be Odoo started with Python 3.
netstat -ant can be used to check port usage. 8069 is for Odoo, 22 is for SSH, and 5432 is for PostgreSQL:
tcp 0 0 0.0.0.0:8069 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
If you don't need Odoo to start with the system, Odoo can now be started manually.
If you want it to start automatically with the system, please continue reading.
Note: You can also try starting with python3.5 odoo-bin -s. What you see in ps aux | grep odoo is like this:
odoo 1058 2.7 1.6 422340 66012 pts/0 Sl+ 12:25 0:00 python3.5 odoo-bin
Started with python3 and python3.5, it seems ctrl + c doesn't shut it down cleanly.
ctrl + c should be able to terminate it, but sometimes it seems it doesn't stop completely and requires a system reboot.
Step 3: Set up the configuration file
3.1
sudo mkdir /etc/odoo
sudo cp /home/odoo/.odoorc /etc/odoo/odoo.conf
sudo chown -R odoo /etc/odoo
3.2 We also need to create a directory for storing Odoo logs, usually located within /var/log:
sudo mkdir /var/log/odoo
sudo chown odoo /var/log/odoo
3.3 Edit the configuration file.
sudo vi /etc/odoo/odoo.conf
Below are 2 suggested values to add :
[options]
logfile = /var/log/odoo/odoo.log
logrotate = True
Brief description:
● addons_path uses comma-separated extension paths. It searches for modules in these paths, reading from left to right, with the leftmost having the highest priority.
● admin_passwd is the master control password used to access the web client database management. It is recommended to set a sufficiently strong password; setting it to False can disable this function.
● The db_user database instance is initialized during the server startup sequence.
● dbfilter is used to filter accessible databases. It is a Python-interpreted regular expression. To prevent users from selecting databases and to ensure unverified URLs work properly, it should be set in the format ^dbname$, for example dbfilter=^odoo-prod$. It supports %h and %d placeholders, which represent the hostname and subdomain of the HTTP request.
● logfile The location where Odoo service logs are written. System service logs are typically located in /var/log. Leave it empty or set it to False, and the logs will be output in the standard way.
● logrotate = True Store logs by day
● proxy_mode should be set to True when using a reverse proxy.
● without_demo should be set to True in the production environment, so that there will be no demo data in the new database.
● The workers value is the number of enabled processors.
● xmlrpc_port The port number that the service listens on. Default is 8069
● data_dir The location where session data and attachments are stored, remember to back it up.
● xmlrpc-interface sets the listening address. The default value listens on all ports 0.0.0.0. When using a reverse proxy, it can be set to 127.0.0.1 to only respond to local requests.
By running the service with the -c parameter, we can check the effect of the configuration:
./odoo-bin -c /etc/odoo/odoo.conf
Note: Because a log file is set, the log will not pop up.
ctrl + c should be able to terminate it, but sometimes it seems it doesn't stop completely and requires a system reboot.
To view the log, you can open another terminal, use the odoo user, and run:
tail -f /var/log/odoo/odoo.log to view logs.
After starting the Odoo service, try creating a database in the interface.
8: Install Chinese font:
sudo apt-get install ttf-wqy-zenhei -y
sudo apt-get install ttf-wqy-microhei -y
9. Install wkhtmltopdf required for reports
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb
sudo dpkg -i wkhtmltox-0.12.2.1_linux-trusty-amd64.deb # It will prompt to install xfonts-75dpi, etc. At this point, use apt-get -f install to install these 2 dependencies
sudo ln -s /usr/local/bin/wkhtmltopdf /usr/bin
sudo ln -s /usr/local/bin/wkhtmltoimage /usr/bin
Step 4: Create the /lib/systemd/system/odoo.service file to enable Odoo to start automatically with the system
Since 16.04 uses systemd as init, configuring Odoo as a service is slightly different.
To check whether your system uses systemd, run the following command:
man init
This will open the documentation for the currently used init system, allowing you to check which one is in use.
If your server uses systemd.
4.1 Edit the /lib/systemd/system/odoo.service file:
sudo vi /lib/systemd/system/odoo.service
The content is as follows:
[Unit]
Description=Odoo
After=postgresql.service
[Service]
Type=simple
User=odoo
Group=odoo
ExecStart=/home/odoo/
4.2 Need to register a new service:
sudo systemctl enable odoo.service
4.3 Enable this new service:
sudo systemctl start odoo
Check its status:
sudo systemctl status odoo
As shown below, Active active(running) indicates correct operation, and we can see it is running under python3.
● odoo.service - Odoo
Loaded: loaded (/lib/systemd/system/odoo.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2017-10-15 12:46:54 CST; 6s ago
Main PID: 930 (python3)
CGroup: /system.slice/odoo.service
└─930 python3 /home/odoo/
If you wish to stop it, use the following command:
sudo systemctl stop odoo
You can also use `service odoo start` and `service odoo stop` to start and stop the service.
Now we can confirm that our Odoo instance has started and can respond to requests.
If Odoo is running normally, we can obtain information from the log files. We can check whether Odoo responds to HTTP requests:
curl http://localhost:8069
To check the log file, we can use:
sudo less /var/log/odoo/odoo.log
You can also use tail -f:
sudo tail -f /var/log/odoo/odoo.log
Today I discovered that the password part in the configuration file of Odoo 11 is also encrypted.
Install odoo8 from source code
English address:
http://www.theopensourcerer.com/2014/09/how-to-install-openerp-odoo-8-on-ubuntu-server-14-04-lts/
Translation address:
http://shine-it.net/index.php?topic=16623.msg29044#msg29044
Reprint address:
http://jointd.com/?p=1998
On September 19, 2014, Odoo officially released version 8.0, a brand new version that integrates multiple functions such as website building.
In Linux-like operating systems, the conventional method to install Odoo is to download a .deb package (for Debian/Ubuntu type Linux systems) or a .rpm package (for Redhat/CentOS type Linux systems) from the corresponding version directory in the Odoo official website's download repository at http://nightly.openerp.com, and then run the installation. However, with this approach, the installation is configured according to Odoo's default settings, leaving little room for personalized configuration and sometimes making management inconvenient. Therefore, we adopt a more hands-on source code installation method, configuring the installation settings ourselves as needed.
This article introduces the method of installing Odoo from source code via Github on the Ubuntu Server 14.04 operating system. The advantages of this approach are:
When the official source code is upgraded, or when there are new bug fixes, if needed, we can update the local code with just a "git pull" command when connected to the network.
Please note that when pulling code in the future, you need to make a backup in advance. In some cases, the Odoo database also needs to be updated.
Step 1 Set up the server and install Ubuntu Server 14.04
Visit the Ubuntu official website server edition page http://www.ubuntu.com/server to download the installation image. Currently, the server edition no longer has a 32-bit version, only a 64-bit version. Alternatively, download the image from the domestic NetEase source: http://mirrors.163.com/ubuntu-releases/14.04/ubuntu-14.04-server-amd64.iso. After downloading, create a bootable CD or USB drive from the image, install it on your computer using the standard method, and remember the username and password you set.
This article uses setting the hostname to odoo and the username to dean as an example for installing the Ubuntu system. In the following steps, if any commands are related to the hostname and username, please change them to your actual hostname and username.
When the installation reaches the step of selecting pre-installed services, select PostgreSQL to install the PostgreSQL database, the data service environment required by Odoo, together.
After the system is installed and restarted, log in with your own username and password, then run
psql –version
Command to check version, currently the version installed with Ubuntu 14.04 server edition is PostgreSQL 9.3.5
Update the server's software source information below:
sudo apt-get update
And update the various software packages on the server, automatically resolving dependencies:
sudo apt-get dist-upgrade
Although not always necessary, it is best to restart the server at this point to update the changed content.
sudo shutdown -r now
Step 2 Create a system user odoo, who will later have the permissions to run the Odoo program
If there are other unloaded disks and you want to install on one of them:
sudo mkdir /opt
sudo mount -t ext4 /dev/xvdb1 /opt
Configure automatic mounting:
First, use the command blkid to view the UUID of the partition.
Add the following configuration to the file /etc/fstab
:
# /devdata was on /dev/sdb
UUID=7016a5f8-30cd-41d7-9c62-3fdbd6b04f29 /opt ext4 defaults 0 0
Run command
sudo adduser --system --home=/opt/odoo --group odoo
The odoo user added here is a system user, used to own and run various background services, rather than a personal user who logs into the system to perform operations. In the above command, the "home" directory for the odoo user is specified and created as /opt/odoo, which is where we will store the odoo program code. You are free to choose the storage location for the code, but please note that the content in some configuration files below is based on the directory specified by the above command. Therefore, when readers choose a different storage location for the code, some settings below must be modified accordingly. Although the system user is prohibited from logging in and has no shell, when we need to perform specific operations as this user, we can still switch users using the su command:
sudo su - odoo -s /bin/bash
This su (Switch User) command will switch your current terminal login to the odoo user and use the /bin/bash shell. After running this command, it will automatically switch your current directory to the odoo user's home directory /opt/odoo. When you have finished operating as the odoo user, you can use
Exit the shell of the odoo user and return to the user you logged in with.
Step 3 Install and configure the database server PostgreSQL
If you did not select to install PostgreSQL together with Ubuntu Server during the installation process, you can install it now:
sudo apt-get install postgresql
If it has already been installed, there is no need to execute this command.
Below, add and configure the odoo user for the PostgreSQL database:
First, switch to the postgres user, which is the default initial user of PostgreSQL. By operating as this user, we have the permission to configure the database:
sudo su - postgres
Then create a new database user odoo as postgres, under which the odoo program will access the PostgreSQL database to create and delete database files.
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt odoo
The system prompts for password entry twice:
Enter password for new role: ********
Enter it again: ********
Remember the password you set here, as you will need it later. Finally, exit the postgres user identity:
Step 4: Install Python runtime libraries and wkhtmltopdf for Ubuntu server
The Python runtime libraries that Odoo version 8.0 depends on are somewhat different from those required by OpenERP version 7.0.
Run command
sudo apt-get install python-dateutil python-docutils python-feedparser python-gdata \
python-jinja2 python-ldap python-libxslt1 python-lxml python-mako python-mock python-openid \
python-psycopg2 python-psutil python-pybabel python-pychart python-pydot python-pyparsing \
python-reportlab python-simplejson python-tz python-unittest2 python-vatnumber python-vobject \
python-webdav python-werkzeug python-xlwt python-yaml python-zsi python-pyPdf \
python-decorator python-passlib python-requests
Odoo version 8.0 switched to using wkhtmltopdf for PDF output, so you need to download wkhtmltopdf and install it:
wget http://sourceforge.net/projects/wkhtmltopdf/files/0.12.1/wkhtmltox-0.12.1_linux-trusty-amd64.deb \
(wget http://download.gna.org/wkhtmltopdf/0.12/0.12.2.1/wkhtmltox-0.12.2.1_linux-trusty-amd64.deb)
Then run
sudo dpkg -i wkhtmltox-0.12.1_linux-trusty-amd64.deb
Proceed with installation.
After installation, copy the executable file to usr/bin
sudo cp /usr/local/bin/wkhtmltopdf /usr/bin/wkhtmltopdf
Change the owner to the root user and add the executable attribute.
sudo chown root:root /usr/bin/wkhtmltopdf
sudo chmod +x /usr/bin/wkhtmltopdf
Test it out by printing a webpage to your home directory:
wkhtmltopdf www.baidu.com ~/baidu.pdf
If it shows that the pdf was successfully output, it indicates that wkhtmltopdf was installed successfully.
Installing Chinese fonts:
sudo apt-get install ttf-wqy-zenhei
sudo apt-get install ttf-wqy-microhei
Why can't these fonts be loaded in Odoo?
After installation here, all runtime-dependent projects for Odoo 8.0 have been installed.
Step 5 Install Odoo Server
First install the git software
sudo apt-get install git
Switch to the odoo user:
sudo su - odoo -s /bin/bash
Use git software to download a set of code from the odoo8.0 branch of the github website (there is no space between the - at the end of the first line and the b at the beginning of the second line in the command below; a space and a dot "." follow the last word of the command)
It is mandatory; this dot indicates the "current directory", not a period):
(If it is found that it cannot be saved to the current directory during download, you can first download it to the specified directory and then move it to that directory)
git clone https://www.github.com/odoo/odoo --branch 8.0 --single-branch .
Or use this:
git clone -b 8.0 https://github.com/odoo/odoo.git .
(There are over a hundred megabytes of data to download. Depending on your internet speed, this will take some time.)
Download the complete branch to the current odoo directory:
git clone https://github.com/odoo/odoo.git .
After all downloads are complete, log out of the odoo user:
Step 6 Configure Odoo Program
Odoo's default configuration file (/opt/odoo/debian/openerp-server.conf) contains basic settings. With a few small modifications, it can run well on our system. Here, we first copy this file
Copy to the required location under /etc:
sudo cp /opt/odoo/debian/openerp-server.conf /etc/odoo-server.conf
Change its ownership and permissions:
sudo chown odoo: /etc/odoo-server.conf
sudo chmod 640 /etc/odoo-server.conf
The above command makes the file owned by the odoo user and group, and only the odoo user and root user can read it.
Edit it with a text editor below. For beginners, it is recommended to use Ubuntu's built-in nano editor. Taking it as an example, run:
sudo nano /etc/odoo-server.conf
Then make 3 changes,
1. After opening this configuration file, at the top of the file, find
db_password = False
In this line, change False after the equals sign to the database password you set when configuring PostgreSQL in step three.
2. Then find
addons_path = /usr/lib/python2.7/dist-packages/openerp/addons
This line, change to
addons_path = /opt/odoo/addons
In this way, the Odoo program will read modules from our custom-installed opt/odoo/addons directory.
3. We also need to specify where Odoo writes its log file. Add a new line at the end of the file
logfile = /var/log/odoo/odoo-server.log
After editing the configuration file, press Ctrl+O, then press Enter to overwrite and save, then press Ctrl+X to exit the nano program.
Now you can try to start the Odoo server to see if it is running normally.
First switch to the odoo user,
sudo su – odoo -s /bin/bash
Then run
/opt/odoo/openerp-server
If the interface feedback you receive is a few lines telling you "OpenERP is running and waiting for connections.", then it's OK. (Although the version has been upgraded, the program is still called OpenERP instead of Odoo in the logs.)
If an error occurs, you need to go back and find where the problem lies. If everything is normal, press Ctrl+C to stop the server, then use
exit
Command to exit the odoo user and return to the shell you are logged into.
Step 7 Install the Startup Script
Starting and stopping the Odoo service involves many modules and requires multiple steps, which is quite cumbersome. Below, we will install a script that will handle these steps in a batch manner. We only need to run this script once, and it will batch process actions such as starting and stopping the Odoo server under the correct user identity.
The odoo program provides a ready-made script, which is the file /opt/odoo/server/install/openerp-server.init, but it requires a small modification—because we did not install it according to odoo's default installation method.
Here is a modified script file that can be downloaded and used: (There is no space between the / at the end of the first line and the o at the beginning of the second line in the command below)
wget http://www.theopensourcerer.com/wp-content/uploads/2014/09/odoo-serverSimilar to the configuration file, you need to copy the downloaded script to /etc/init.d/ and name it odoo-server:
sudo cp ~/odoo-server /etc/init.d/odoo-server
Then change it to an executable file, owned by the root user:
sudo chmod 755 /etc/init.d/odoo-server
sudo chown root: /etc/init.d/odoo-server
In the configuration file we edited in step six, we specified the storage location for the Odoo server's log files. Now
We need to create that directory so the Odoo server can write logs into it, and we also need to make this location readable and writable by the Odoo user:
sudo mkdir /var/log/odoo
sudo chown odoo:root /var/log/odoo
Step 8 Test the Server
To start the Odoo server, enter:
sudo /etc/init.d/odoo-server start
Now you can check the log file to see if the server has started.
less /var/log/odoo/odoo-server.log
(To exit the less command viewing interface, simply press the q key)
If problems occur during server startup, you can check the log file for the cause.
If everything is normal, you can now access the Odoo web page using a web browser, with the address format:
http://IP or domain name of Odoo server:8069
For example, if the IP address of the Odoo server is 192.168.1.10, then on other computers within the same local area network, open a web browser (since Odoo uses the newer HTML5 standard, it cannot display properly on IE6 that comes with Windows XP; it is recommended to download and install a new version of Chrome or Firefox browser), and enter the following in the address bar:
http://192.168.1.10:8069
You should be able to see the Odoo database management interface. Since it is a fresh installation and no account set has been created yet, it will default to this interface.
It is recommended that the reader modify the master password of the Odoo system at this point and remember it firmly. This password is used to create, copy, delete, back up, and restore databases, and it carries significant authority. It is best to set a strong password. Default
The master password is "admin", which is relatively insecure. This password is written in plain text in the /etc/odoo-server.conf file. This is also why we set this file to be readable only by the odoo user and root.
When you modify and save a new master password on the web interface, the file /etc/odoo-server.conf will be overwritten, and some additional options will appear.
Check below whether the odoo server can be properly stopped:
sudo /etc/init.d/odoo-server stop
Check the log file to confirm that the service has stopped. You can also use the top command to view the process table of the running Ubuntu server to verify. (To exit the top command interface, also press the q key)
Step 9 Automating Odoo Startup and Shutdown
If all the previous steps run normally, the final step is to make the startup script automatically start and stop the Odoo service when the Ubuntu server is powered on and off.
sudo update-rc.d odoo-server defaults
If you like, you can restart your server now. When you log in again, Odoo should already be running. If you enter
ps aux | grep odoo
You will see a message like the one below:
odoo 1491 0.1 10.6 207132 53596 ? Sl 22:23 0:02 python /opt/odoo/openerp-server -c /etc/odoo-server.conf
This shows that the server is running normally. Of course, you can also check the log files or verify by accessing it with a web browser.
