Odoo is very well known ERP system today. Odoo 9 provides great features that will help to grow business. By default odoo runs over port 8069. So we are accessing server using domain:8069. What if we need to access server using only domain like a standard website? We can do it by configuring web server with odoo. Here I am going to show you configuration of Apache web server for odoo.
Before configuring apache with odoo, first check whether apache web server is installed on your machine or not. If not installed then execute below command to installed it.
sudo apt-get update
sudo apt-get install apache2
After installing apache on your machine, you need to enable some modes by executing below commands.
sudo a2enmod proxy proxy_http
Now go to the directory, “/etc/apache2/sites-available” and create a file with <domain-name>.conf. Here I am going to use “openerp.iplantoo.com” domain for my odoo server. So the file name will be “demo.surekhatech.conf”. Add the below content into this file.
<VirtualHost *:80>
ServerName openerp.iplantoo.com
ServerAlias openerp.iplantoo.com
LogLevel warn ErrorLog /var/log/apache2/openerp.iplantoo.com.error.log CustomLog /var/log/apache2/openerp.iplantoo.com.access.log combined
ProxyPass / http://localhost:8069/ ProxyPassReverse / http://localhost:8069/ </VirtualHost>
After adding the virtual host for odoo server, you need to enable site using the following command.
sudo a2ensite openerp.iplantoo.com.conf
A message will appear showing that site is enabled. After that you need to restart the apache server by executing below command.
sudo service apache2 restart
Make the host file entry in case you have made the configuration on the local machine. Open the “hosts” file by executing below command:
sudo nano /etc/hosts
Add the following entry into this file.
127.0.0.1 openerp.iplantoo.com
After completing with above configuration, you can access the odoo server by hitting the “openerp.iplantoo.com” in any browser. You can see that the odoo server is running over the “http”. But what if we need to run our odoo server over more secure channel i.e. “https”.
For that you need SSL certificate and key. You can buy the certificate from any trusted vendor. You can also generate certificates and used it. Certificate can be generated using the openssl toolkit. For linux machine you can generate certificate by using the following commands.
To generate key:
openssl genrsa -out openerp.iplantoo.com.key 2048
To generate Certificate:
openssl req -new -x509 -key openerp.iplantoo.com.key -out openerp.iplantoo.com.cert -days 3650
-subj /CN=openerp.iplantoo.com
Once you have SSL key and certificate, you need to update the existing virtual host to run odoo server over “https”. Before that first enable the apache SSL mode by executing below command.
sudo a2enmod ssl
Now open “demo.surekhatech.conf” file from the “/etc/apache2/sites-available” and update the virtual host with the below contents.
<VirtualHost *:80>
ServerName openerp.iplantoo.com
ServerAlias openerp.iplantoo.com
Redirect / https://openerp.iplantoo.com/
</VirtualHost>
<VirtualHost *:443> ServerName openerp.iplantoo.com ServerAlias openerp.iplantoo.com
LogLevel warn ErrorLog /var/log/apache2/openerp.iplantoo.com.error.log CustomLog /var/log/apache2/openerp.iplantoo.com.access.log combined
SSLEngine on SSLProxyEngine on SSLCertificateFile /etc/apache2/ssl/openerp.iplantoo.com.cert SSLCertificateKeyFile /etc/apache2/ssl/openerp.iplantoo.com.key
ProxyPreserveHost On ProxyPass / http://localhost:8069/ retry=0 ProxyPassReverse / http://localhost:8069/ </VirtualHost>
Here we have added the path for the SSL certificate and key file. Create a directory with “ssl” name on “/etc/apache2” location. Copy the SSL certificate and key files into “/etc/apache2/ssl” directory.
Now restart the apache web server using the following command.
sudo service apache2 restart
Open any browser and hit the url “openerp.iplantoo.com”. You can see that it will automatically redirect your odoo server over “https”, a more secure channel. Any request to your odoo server will be serve over the “https”.
For more implementation details or support you may contact us at 该邮件地址已受到反垃圾邮件插件保护。要显示它需要在浏览器中启用 JavaScript。.