Setting Up OpenERP (Odoo) 9 with Nginx on RHEL/CentOS and Debian/Ubuntu


On RHEL/CentOS and Debian/Ubuntu, install Nginx, PostgreSQL, and Python requirements before configuring OpenERP (Odoo) 9 with Nginx. For OpenERP, create a PostgreSQL database and user. Extract the OpenERP source code by downloading it. Edit the configuration file to configure OpenERP. As a reverse proxy, configure Nginx to reroute requests. Setup Nginx to directly serve static files. Launch OpenERP and switch on automatic startup. To permit inbound connections, modify the firewall's rules. Access OpenERP through Nginx to check the configuration. Through this procedure, OpenERP 9 will be successfully installed alongside Nginx on RHEL/CentOS and Debian/Ubuntu.

Methods Used

  • Manual Configuration

  • Docker Installation

Manual Configuration

There are several stages involved in manually configuring Nginx and OpenERP (Odoo) 9 on RHEL/CentOS. The RHEL/CentOS system is first set up with the necessary requirements for Nginx, PostgreSQL, and Python. The OpenERP source code is then extracted to the specified location after being downloaded. The relevant settings, including the specifics of the database connection, the ports, and the log files, are then added to the OpenERP configuration file. Its configuration file is altered to reroute requests to the OpenERP server using the proper proxy settings, enabling Nginx to function as a reverse proxy. For better performance, Nginx is also set up to serve static files directly. The OpenERP server is then launched and set up to launch automatically when the system boots. Inbound connections are permitted by changing the firewall's rules.

This manual configuration procedure offers freedom and control over the configuration parameters and ensures the successful installation of OpenERP 9 with Nginx on RHEL/CentOS systems.

Algorithm

  • Install the necessary Python, PostgreSQL, and Nginx dependencies.

sudo yum install nginx
sudo yum install postgresql-server
sudo yum install python3 python3-pip
  • Extract the OpenERP source code by downloading it.

wget https://github.com/odoo/odoo/archive/9.0.tar.gz

tar -xvf 9.0.tar.gz
  • Set up PostgreSQL for OpenERP by making a new database and user.

sudo su - postgres

createdb myopenerpdatabase

createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt myopenerpuser
  • Modify the OpenERP configuration file by adding the essential settings, such as the ports and database connection information.

cd /path/to/odoo-9.0

cp odoo.conf.template odoo.conf
vi odoo.conf
  • Edit Nginx's configuration file to set it up as a reverse proxy, which will forward requests to the OpenERP server.

sudo vi /etc/nginx/nginx.conf
  • Add the next configuration inside the http block:

server {
   listen 80;
   server_name your_domain.com;

   location / {
      proxy_pass http://127.0.0.1:8069;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
   }
}
  • To boost performance, set Nginx to serve static files directly.

sudo vi /etc/nginx/nginx.conf
  • Add the next configuration inside the http block:

http {
   # ...

   location /web/static/ {
      root /path/to/odoo-9.0/;
   }

   # ...
}
  • Launch the OpenERP server and configure it to launch immediately after booting.

python3 /path/to/odoo-9.0/odoo-bin -c /path/to/odoo-9.0/odoo.conf

sudo systemctl enable odoo
  • Modify the firewall rules so that connections to the OpenERP server from outside are permitted.

sudo firewall-cmd --add-service=http --permanent

sudo firewall-cmd --reload
  • Check the configuration by logging into OpenERP using the Nginx server.

Docker Installation

Install Docker first on your PC before configuring OpenERP (Odoo) 9 with Nginx on Debian/Ubuntu. Pull the OpenERP 9 Docker image from the official Docker repository after installing Docker. To allow container communication, set up a Docker network. Create a PostgreSQL container, then set it up so that it creates a database just for OpenERP. Run the OpenERP container while making sure to include the required database connection information. To send incoming requests to the OpenERP container, configure Nginx as a reverse proxy. Adapt Nginx's settings so that static files are served directly. Start Nginx and make sure it boots along with the computer. Finally, modify the firewall rules to permit Nginx inbound connections.

The advantages of containerization are offered by this method, which also makes setup easier and creates a scalable and controllable environment for OpenERP with Nginx on Debian/Ubuntu.

Algorithm

  • Start

  • Docker must be configured on a Debian or Ubuntu desktop.

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
  • Download the OpenERP 9 Docker image from the official Docker repository.

sudo docker pull odoo:9
  • Establish a Docker network for communication between containers.

sudo docker network create odoo_network
  • Configure and modify a PostgreSQL container to create an OpenERP database.

sudo docker run -d --name db_container --network=odoo_network -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres postgres:12
  • Launch the OpenERP container while supplying the required database connection information.

sudo docker run -d --name odoo_container --network=odoo_network -p 8069:8069 --link db_container:db -t odoo:9
  • Set up Nginx to act as a reverse proxy, rerouting traffic to the OpenERP container.

server {
   listen 80;
   server_name your_domain.com;

   location / {
      proxy_pass http://localhost:8069;
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
   }
}
  • To enable direct serving of static files, alter Nginx's settings.

  • Add this line to the server block withinside the Nginx default configuration file (which include at /etc/nginx/sites-available/default):

location /web/static/ {
   proxy_cache_valid 200 60m;
   proxy_buffering on;
   expires 864000;
     proxy_pass http://localhost:8069;
}
  • Launch Nginx and make sure it launches at system startup.

sudo service nginx start
  • Modify the firewall settings to permit Nginx inbound connections.

sudo ufw allow 80/tcp
  • End

Conclusion

In conclusion, installing the required dependencies, configuring OpenERP, and setting up Nginx as a reverse proxy are all steps in the process of installing OpenERP (Odoo) 9 with Nginx on RHEL/CentOS and Debian/Ubuntu. The setup parameters are flexible and under your control using the manual configuration technique, enabling adjustments based on particular needs. The advantages of containerization, on the other hand, are provided by the Docker installation method, which also offers scalability and manageability while streamlining the setup procedure.

Users can successfully implement OpenERP 9 with Nginx by using either the manual setup or Docker installation method, providing effective administration of corporate operations and assuring a seamless user experience. The decision between the two approaches is based on personal preferences, amount of knowledge, and particular deployment requirements. As a result, both RHEL/CentOS and Debian/Ubuntu systems can run OpenERP 9 with Nginx thanks to the setup process.

Updated on: 03-Aug-2023

86 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements