How to install ERPNext on Centos7

The guys at ERPNext have done a great job on creating an installation script that install the full functional system in one easy step. But my initial attempts to install it on the Centos 7 by following easy installation procedure was a failure. I think this was mainly because the script has been developed and tested mainly for Ubuntu. You might be lucky enough to have your system set up exactly as the script expects but if that is not the case there will be a lot of trials and errors and re-builds and head scratches.

The guys at ERPNext have done a great job on creating an installation script that install the full functional system in one easy step. But my initial attempts to install it on the Centos 7 by following easy installation procedure was a failure. I think this was mainly because the script has been developed and tested mainly for Ubuntu. You might be lucky enough to have your system set up exactly as the script expects but if that is not the case there will be a lot of trials and errors and re-builds and head scratches.

For main installation guides refer to: http://frappe.github.io/frappe/user/en/bench/guides/

and https://github.com/frappe/bench

To save you (and myself on the future deploys) some time on installation process, I listed full steps I took to install and run it successfully in my fresh Centos 7 minimal virtual machine.

All the details and screenshots are correct for below:

OS: Centos 7 ( Linux 3.10.0-327.4.5.el7.x86_64)
ERPNext: 6.27.16
Frappe Framework: 6.27.17
Database: MariaDB  10.0.25

Preparation

After installing Centos make sure you update it. You also will need wget package to download the script (it is not part of minimal package). I also use vim as my default editor so will install that too.

yum install vim wget 
yum update

By default, in Centos7 installation SELinux is set to enforce. You need to disable this during the installation.

sudo vim /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

Change the value in the 7th line from enforcing to disabled.

Also by default firewall is enabled and blocking all the incoming ports. I simply add my ports to the default public zone.

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-port=8000/tcp
sudo firewall-cmd --reload

To make sure the ports have been added properly run below command and check the result:

[saeed@erpnext ~]$ firewall-cmd --list-all
public (default, active)
interfaces: eno18977984
sources:
services: dhcpv6-client http ssh
ports: 8000/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:

[saeed@erpnext ~]$

Then do a reboot and system should be ready to download and install the ERPNext.

sudo reboot

Install ERPNext

Download and set up ERPNext

If you run the installation script with your admin user and sudo, it will use your current user as frappe user. But if you run the script as root it will create a new user called frappe and use it for the next steps of maintenance and updates. I would prefer to have a new dedicated user for this service so will run my script as root.

sudo mkdir /opt/erpnext
sudo cd /opt/erpnext
sudo wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py
sudo python install.py --production --user frappe

Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
base: mirror.nsw.coloau.com.au
extras: mirror.internode.on.net
updates: mirror.internode.on.net
Resolving Dependencies
--> Running transaction check
.
.
.
TASK [bench : Restart the bench] * * * * * * * * * * *
changed: [localhost]
PLAY RECAP *********************************************
localhost : ok=81 changed=33 unreachable=0 failed=0
Frappe/ERPNext has been successfully installed!

$

It takes a while to install all the requirements and also database installed and configured. Sit back and be patient while the installer does the job.

Installer will prompt you to enter for two passwords. First one is for the mysql database user password. Another one for erpnext Administrator user password. The passwords you entered will be stored at /home/frappe/passwords.txt
You can remove this file after making a note of the passwords.

Setting up first site

All the next steps will be done under frappe user. So have the password handy or change it to something easier to remember.

Also, you will need sudo privilege in some stages so add it to wheel group.

sudo usermod -aG wheel frappe

Set up your ERPNext site

By default, a site called site1.local is created. You can either use that or create your own new site. To avoid creating another new database I use that same site just rename it to whatever I want.

Sites are instances of the erpnext, each with its own database and settings. So unless you want to run multiple companies in isolation from each other; you will need just a single site.

$ sudo su frappe  
[frappe@erpnext ~]$ cd /home/frappe/frappe-bench/
[frappe@erpnext frappe-bench]$ mv sites/site1.local sites/mysite.domain
[frappe@erpnext frappe-bench]$ sudo bench setup production frappe
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Restarted supervisord

That should be all you need to do on the server.

Clean-up

Remove frappe user from wheel group.

sudo usermod -G "" frappe

Access to website

To get to the website from another machine, you need to add the site ip to your dns server and access to the server. It won’t work with ip address in web browser (can’t figure out why at this stage).

I am using a Windows machine as client, so just locally add the ip address to my hosts file. You can do it by editing hosts file in: c:/program files/window/system32/drivers/etc/hosts

Open the file in Notepad (or any other text editor) as Administrator and add a line for the website and save it.

10.1.1.55            mysite.domain

windows-hosts-file

That should be it. Enjoy ERPNexting.

Migrate cloud database to local server

If you have a current database on erpnext.com and want to have a local copy of it. Follow below steps:

First make a backup of the online server.

Go to Setup > Download Backups and select the most recent backup.

Transfer the .sql file to your server. (i use pscp from putty)

On the server that you have the new ERPNext installation follow below steps:

gunzip 20160528_72912243_database.sql.gz
mysql -u root -p erpnext-db-name < 20160528_72912243_database.sql
cd ~/frappe-bench
bench --site mysite.domain migrate

There are few apps that is installed in online version and I don’t have them in local version. So need to remove them before the site can work.

30 Comments

  1. saeed great work man , i was trying to install from last two days but cannot find proper solution.
    thank you for very much for your information

    1. it is hard to say without knowing the errors. where are you trying to load the page from? I installed it on headless server and browsing from my windows machine with no problem.

      1. I also realised non of my screenshots in the posts are loading. I am investigating it and should be fixed soon.

  2. thank you waitng for your update.
    what i am facing problem after successful installation on port 80 nginx is using default page,
    {Frappe/ERPNext is installed successfully and is running on port 80.}
    i had tried to make new port 8080 but webpage is refusing connection.
    any idea or help?

    1. it might be your firewall that drops your traffic on new port. Have you added it to your public zone?
      To test that you can temporarily disable the firewall with:

      sudo systemctl stop firewalld

      and see if that changes anything

      1. to see all the open services and ports:

        firewall-cmd --list-all 

        To add your ports to accesslist:

        sudo firewall-cmd --permanent --zone=public --add-port=8080/tcp
        sudo firewall-cmd --reload 
  3. Dear Saeed,
    Please place a detailed and step-by-step guide to install ERPNext.com platform from manual installation points of view.

    The guys out there are doing good job but it looks like some commits having bad impact on the overall performance.

    Please go through and provide clear manual installation guide for the components named Bench, Frappe Framework and ERPNext.

    They are calling the last two as Apps based on the 1st one as somehow engine.

    Please assume that, non-skilled users like me are looking for installation specific versions of any of the above, in particular Frappe Framework which is not clear out there.

    Please consider Ubuntu 14.04, MariaDB, Redis, NodeJS and WKHTMLtoPDF with patched QT.

    Assume the source is available for any which is not supposed to be the latest ones.

    Thank you!

  4. Hi,

    I tried to follow almost all steps, but I missed the Centos 7 upgrade. This is necessary due to the fact that there is a problems with initializing some services.

  5. Hello

    when i was trying the installation. i have error on this.
    Error was : Failed to start The ngix HTTP and reserve proxy server.
    nginx.service failed.

    please help me out for this.

    1. Hi Tanvir,
      unfortunately from the minimal information you have given here i can not see the issue behind. It appears to be nginx problem rather than ERPNext.
      I would recommend you just google the error message and you will find plenty of answers.

  6. Hey Saeed, Thanks for sharing this!
    Also, the reason why you can’t access by IP-address, is because of the default server-block in /etc/nginx/nginx.conf. So it serves the “welcome to nginx fedora yadayada” from /usr/share/nginx/html by default. If you comment the server-block out in the config file, you can access by IP.

    Cheers!

  7. Hi Saeed.I have followed this guide and installed erpnext without error,But my problem is ,how do i access it.Am using digitaloceans vps server running on Centos7.Regards

    1. have you got a domain name registered for your service? if yes then you need to replace mysite.domain in the instruction with your domain name and access it through the browser with that address.

      If not, then you need to change the settings in your nginx.conf as @Mads has described few comments above. And use the IP address of your server to access the site.
      Hope this helps 🙂

  8. Hello Sir,

    I got error while running the script on wkhtmltopdf that stop and doesn’t continue. but do some comment and able to install it.. now my problem is how to install the wkhtmltopdf when i try to view my printing in PDF i can’t view it. any suggestion please..

    Thanks
    jun

  9. ERPnext installation successfully 🙂 but when i try to getiing access it from web it says Welcome to nginx on Fedora! ERPlogin page display … please can anyone help me ?

    1. 1st of all thank you @Saeed for sharing this guide.

      @dinesh panchal

      comment the default server and root from etc/nginx/nginx.conf

      sudo vim /etc/nginx/nginx.conf

      press i to change to insert mode

      comment the following:
      # listen 80 default_server;
      # listen [::]:80 default_server;
      # server_name _;
      # root /usr/share/nginx/html;

      press Esc

      :x!

      then restart nginx service:

      sudo service nginx restart

  10. Hello

    i want database of erpnext with its contents ..
    how can i get it ??
    .sql file is backup but that is without content.

  11. Hi Experts,

    I got error while running the script on wkhtmltopdf that stop and doesn’t continue.
    while downloading wkhtmltopdf their server is not responding..

    Please solve this issue as soon as possible.
    update setup_frappe.sh

  12. Hi,

    Thanks for this.

    When following your instructions, I ran into this error

    “`
    [/opt/erpnext]# Failed to execute operation: Too many levels of symbolic links
    “`

    Please, what do I do here?

Leave a Reply

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