How to install Odoo with WSGI
Knowledgebase Article
}
Knowledgebase Article
At Kualo we support any application that has the possibility to run on Linux. We are just not happy enough to host them, we want them to run as fast as possible and take away the administration process from our clients responsabilities, the administration needs to be simple. Odoo is not an exception, we have spent many hours running tests with Odoo and creating our own integration with cPanel control panel. The way we setup Odoo is vaguely documented on their office documentation site, we deploy Odoo using WSGI and then create two sub processes to take care of CronJobs and IM Chat (Longpolling). By splitting these services and running Odoo as WSGI, we ensure the best performance and the best use of server resources.
Below you have the instructions required to host Odoo with our services.
If you are not yet a client we invite you to take a look to our plans here: https://www.kualo.com/webhosting/odoo-hosting
The first thing we need to do is to create the account we will use to host our Odoo application. Go to WHM panel and create a new account.
You can review our article here
The first thing we need to do is to configure the Python virtual enviroment. Go to cPanel and click on Setup Python App:
Check the documentation and take notes of the python version required:
Click on Create Application and setup the environment. To ensure compatibility with our Odoo Control plugin, the application needs to be installed on my_apps/odoo:
Finally, click on Create.
After your create the application, you will receive the command to access the virtual enviroment. Login via SSH, and access your virtual enviroment.
In this tutorial, we will install Odoo 14 which at the momento of writting this article it's the latest version. Let's download Odoo using GIT:
rm -rf public
git clone https://www.github.com/odoo/odoo --depth 1 --branch 14.0 ~/my_apps/odoo/odoo
Now, let's access the odoo14 folder and install Odoo with all required modules:
(odoo:3.7)kualotest@hostname ~/my_apps/odoo $ cd odoo
(odoo:3.7)kualotest@hostname ~/my_apps/odoo/odoo $ pip install ./
Odoo will be added as Python Module and can easily be upgraded later. Do not delete this folder as you will the addons folder.
We need now a database and PostGreSQL user we can use with Odoo. Go to cPanel > Databases > PostgreSQL Databases and create the database, username and password.
Remember to assing your user to the database.
The first thing we need to do is to initiallize Odoo database. Let's use the odoo-bin from odoo14 folder and execute the following command:
(odoo:3.7)kualotest@hostname ~/my_apps/odoo $ python odoo/odoo-bin --init --addons-path=odoo/addons --db_host=localhost --db_user=YOUR-PG-USER --db_password="YOUR-PG-PASSWORD" -d YOUR-PG-DBNAME --stop-after-init
That will create the database and install the basic modules, it will add your Odoo filestore at the following location:
/home/YOUR-USERNAME/.local/share/Odoo/filestore
If you don't want DEMO content, you can pass the --without-demo="all" as argument.
In order to access Odoo, we will need to configure the passenger_wsgi.py which will act as our entry point. You can use the following sample:
# WSGI Handler sample configuration file. # # Change the appropriate settings below, in order to provide the parameters # that would normally be passed in the command-line. # (at least conf['addons_path']) # # For generic wsgi handlers a global application is defined. # For uwsgi this should work: # $ uwsgi_python --http :9090 --pythonpath . --wsgi-file openerp-wsgi.py # # For gunicorn additional globals need to be defined in the Gunicorn section. # Then the following command should run: # $ gunicorn odoo:service.wsgi_server.application -c openerp-wsgi.py import sys,os import odoo #---------------------------------------------------------- # Common #---------------------------------------------------------- odoo.multi_process = False # Nah! # Equivalent of --load command-line option odoo.conf.server_wide_modules = ['web'] conf = odoo.tools.config conf['addons_path'] = '/home/YOUR-USERNAME/my_apps/odoo/odoo/addons' conf['db_user'] = 'YOUR-PG-USER' conf['db_password'] = 'YOUR-PG-PASSWORD' conf['db_name'] = 'YOUR-PG-DATABASE' conf['db_host'] = '127.0.0.1' conf['db_port'] = 5432 conf['db_template'] = 'template1' #conf['dbfilter'] = '^YOUR-PG-DATABASE$' conf['data_dir'] = '/home/YOUR-USERNAME/.local/share/Odoo/filestore' conf['admin_passwd'] = 'YOUR-MASTER-PASSWORD' #---------------------------------------------------------- # Generic WSGI handlers application #---------------------------------------------------------- application = odoo.service.wsgi_server.application odoo.service.server.load_server_wide_modules()
Make sure to replace that with your information. You can now access your website and login with the defaults:
username: admin
password: admin
Now that Odoo is running, we need to enable the Crons and IM Chat, we can do this from cPanel > Software > Odoo Control
Select the RAM you desire and start the processes:
That's all. Now you have a complete Odoo installation working.
Powered by WHMCompleteSolution