Running Odoo on a VPS with WHM and cPanel

I’ve been running Odoo on a Linode (1GB). I used Ubuntu 16.10 and the LAMP stack and things worked quite well. For what it’s worth, with three not-very-intense users, Odoo with inventory, accounting, sales, and project worked quite well on that minimal system.

Because I wanted easier management of the system, I decided to switch to a system with WHM and cPanel, which I use on my main web server. Because part of my plan was to also install Openfire, I resized the Linode to a 4GB system, switched to CentOS 7, and installed cPanel. I looked for any discussions of running Odoo on such a system, because it has its own web server. There were a few comments such as, “If you just have SSH, you can install it just fine.”

That’s not quite the case. I have insufficient experience to tell you whether you will experience these same issues, but I’m going to provide my steps and describe my problems along with links to those web sites or forum discussions that provided the way forward. I hope this will help someone else who is trying to do the same thing.

I first installed CentOS 7 (64 bit) and cPanel, which I’ve done before. I also use the csf firewall as part of security. It’s a good idea to go through one of the many “hardening” processes that you’ll find around the web, but the most important thing is to use the security evaluation that csf provides. I’m not going to discuss that in any detail here. I had a couple of accounts hacked on a WHM server some time back and I’ve become paranoid, with the result that I have had no difficulties since that one experience.

My first link is Install Odoo 10 on CentOS 7 with Apache as a reverse proxy. This provided a good basis for the installation.

You can go through the process up to the point of creating the reverse proxy. You may want that code a bit later, but the process is not that straightforward.

After installing Odoo according to the instructions above, you will likely need to correct the version of wkhtmltopdf that you have installed. Just follow the link and install 0.12.4. The reasons for this are discussed elsewhere. I just copied the files over the directories and Odoo is again producing PDFs as ordered.

Now a bit of a diversion. I took a backup of my database for Odoo, which does include file attachments. I first restored all my apps, and then  restored the database to the new server. Once I had opened port 8069 in the firewall, everything started to work just fine. I found the database backup and restore process quite straightforward.

About an hour later, as I was tweaking this and that, Odoo stopped functioning, giving me a 500 error no matter what I tried. After some research, it turns out that cPanel was overwriting the pg_hba.conf file for postgresql, which was in turn preventing Odoo from opening. You can see the details of why this is in the various links, so I’m not going to try to repeat it. I’m new to postgresql as well.

I altered pg_hba.conf as indicated here, and Odoo worked for a few minutes and then died again. (I’m researching just what the security risks of this setting are, but as I noted already, I’m not a postgresql expert, so I’m not certain. I’m hoping it’s not too bad, considering this is a one user system.) My cPanel was saving me from myself again. For all I know, it’s truly for my own good, but I need Odoo to work. To fix this, I followed the instructions in this cPanel forum discussion. Specifically, I used the following line to prevent modification of the file:

chattr +ia /var/lib/pgsql/data/pg_hba.conf

This is definitely a hack, and I do want to discover a better way to handle it, but thus far I have not.

Finally, I wanted to have SSL on my Odoo installation, which I had accomplished through a reverse proxy file similar to the one in my original link, but including the appropriate SSL info. At the same time it’s nice to eliminate the “:8069” in the URL. Without SSL, you can find the right code here. Note especially where the code is placed. I tried several times to make this work as a modification to the site’s entry in httpd.conf, by creating an include file according to the directions. The include was there in the rebuilt httpd.conf file, but I couldn’t get the proxy to work.

On my WHM I went to Apache Configuration, then Include Editor, and I placed the file in the PreVirtual Host Include. At first I thought this wouldn’t work, but it doesn. I believe that what happens is that the virtual host file for your particular domain (I use a subdomain for it) overrides the later options. You’ll lose SSL for some ports, but I don’t use FTP or email (etc) with the subdomain in any case.

Since the code in the link I provided is without SSL, here’s a link to examples with SSL.

That code would also be placed in the PreVirtual Hosts section.

Similar Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.