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.

42 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

      1. Thank you … Bro ๐Ÿ™‚

        Why ERPnext login page is not display.

  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?

  13. Hello, in my case, at TASK [bench : python2 bench init for production] installer crashes with a very long error. Most errors says something like this: npm ERR! prepareGitDep npm ERR!.

    /home/frappe/.npm/_logs/2019-03-13T00_34_58_211Z-debug.log file says this:

    32161 silly lifecycle parchment@2.0.0-dev~prepare: Args: [ ‘-c’, ‘npm run build’ ]
    32162 silly lifecycle parchment@2.0.0-dev~prepare: Returned: code: 1 signal: null
    32163 info lifecycle parchment@2.0.0-dev~prepare: Failed to exec prepare script
    32164 verbose stack Error: parchment@2.0.0-dev prepare: `npm run build`
    32164 verbose stack Exit status 1
    32164 verbose stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
    32164 verbose stack at EventEmitter.emit (events.js:189:13)
    32164 verbose stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
    32164 verbose stack at ChildProcess.emit (events.js:189:13)
    32164 verbose stack at maybeClose (internal/child_process.js:970:16)
    32164 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
    32165 verbose pkgid parchment@2.0.0-dev
    32166 verbose cwd /home/frappe/.npm/_cacache/tmp/git-clone-bb22a6ac
    32167 verbose Linux 2.6.32-042stab131.1
    32168 verbose argv “/usr/bin/node” “/usr/lib/node_modules/npm/bin/npm-cli.js” “install” “–dev” “–prod” “–ignore-prepublish” “–no-progress” “–no-save”
    32169 verbose node v10.15.3
    32170 verbose npm v6.4.1
    32171 error code ELIFECYCLE
    32172 error errno 1
    32173 error parchment@2.0.0-dev prepare: `npm run build`
    32173 error Exit status 1
    32174 error Failed at the parchment@2.0.0-dev prepare script.
    32174 error This is probably not a problem with npm. There is likely additional logging output above.
    32175 verbose exit [ 1, true ]

    NPN and NODEJS versions are:

    root@vps [/opt/erpnext]# node -v
    v10.15.3
    root@vps [/opt/erpnext]# npm -v
    6.4.1

    Any idea?

    Thanks
    Jaime

  14. This is another log (/home/frappe/.npm/_logs/2019-03-13T01_21_39_367Z-debug.log):

    1593 verbose prepareGitDep undefined: installing devDeps and running prepare script.
    1594 error prepareGitDep 1>
    1594 error prepareGitDep > uws@9.14.0 install /home/frappe/.npm/_cacache/tmp/git-clone-162a8966/node_modules/uws
    1594 error prepareGitDep > node-gyp rebuild > build_log.txt 2>&1 || exit 0
    1594 error prepareGitDep
    1594 error prepareGitDep
    1594 error prepareGitDep > wd@1.11.1 install /home/frappe/.npm/_cacache/tmp/git-clone-162a8966/node_modules/wd
    1594 error prepareGitDep > node scripts/build-browser-scripts
    1594 error prepareGitDep
    1594 error prepareGitDep
    1594 error prepareGitDep > sauce-connect-launcher@1.2.4 postinstall /home/frappe/.npm/_cacache/tmp/git-clone-162a8966/node_modules/sauce-connect-launcher
    1594 error prepareGitDep > node scripts/install.js || nodejs scripts/install.js
    1594 error prepareGitDep
    1594 error prepareGitDep
    1594 error prepareGitDep > parchment@2.0.0-dev prepare /home/frappe/.npm/_cacache/tmp/git-clone-162a8966
    1594 error prepareGitDep > npm run build
    1594 error prepareGitDep
    1594 error prepareGitDep
    1594 error prepareGitDep > parchment@2.0.0-dev build /home/frappe/.npm/_cacache/tmp/git-clone-162a8966
    1594 error prepareGitDep > webpack –config webpack.conf.js
    1595 error prepareGitDep 2> npm WARN install Usage of the `–dev` option is deprecated. Use `–only=dev` instead.
    1595 error prepareGitDep npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead:
    1595 error prepareGitDep npm WARN deprecated npm i nyc
    1595 error prepareGitDep npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.
    1595 error prepareGitDep npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance only, flatted is its successor.
    1595 error prepareGitDep npm WARN deprecated nodemailer@2.7.2: All versions below 4.0.1 of Nodemailer are deprecated. See https://nodemailer.com/status/
    1595 error prepareGitDep npm WARN deprecated babel-preset-es2015@6.24.1: Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
    1595 error prepareGitDep npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
    1595 error prepareGitDep npm WARN deprecated mailcomposer@4.0.1: This project is unmaintained
    1595 error prepareGitDep npm WARN deprecated socks@1.1.9: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
    1595 error prepareGitDep npm WARN deprecated uws@9.14.0: New code is available at github.com/uNetworking/uWebSockets.js
    1595 error prepareGitDep npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
    1595 error prepareGitDep npm WARN deprecated buildmail@4.0.1: This project is unmaintained
    1595 error prepareGitDep npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
    1595 error prepareGitDep npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
    1595 error prepareGitDep npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
    1595 error prepareGitDep /home/frappe/.npm/_cacache/tmp/git-clone-162a8966/node_modules/webpack-cli/bin/config-yargs.js:89
    1595 error prepareGitDep describe: optionsSchema.definitions.output.properties.path.description,
    1595 error prepareGitDep ^
    1595 error prepareGitDep
    1595 error prepareGitDep TypeError: Cannot read property ‘properties’ of undefined
    1595 error prepareGitDep at module.exports (/home/frappe/.npm/_cacache/tmp/git-clone-162a8966/node_modules/webpack-cli/bin/config-yargs.js:89:48)

  15. My install experience is pretty straight forward using the installer script. Before installation though you need to pre-install the dependencies like; wget, nginx, dnsmasq, net-tools and bind-utils. I do experience from time to time that the installer stops so you need to add or less this dependencies.

  16. How to setup https
    Set DNS Multitenancy on by running sudo bench config dns_multitenant on
    Add custom domain to site1.local by running sudo bench setup add-domain erp.example.com and enter site1.local when asked
    Setup letsecrypt by running sudo -H bench setup lets-encrypt site1.local –custom-domain erp.example.com

  17. sudo adduser clerpnext
    sudo usermod -aG wheel clerpnext
    sudo passwd clerpnext

    sudo su clerpnext
    cd ~
    wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py

    sudo python install.py –develop –user clerpnext
    #sudo python install.py –production –user clerpnext

    cd ~/frappe-bench
    sudo bench config dns_multitenant on
    mv sites/site1.local sites/erpnext.centrelinetechnologies.com
    bench setup nginx

    sudo bench setup production clerpnext
    #sudo service nginx reload

  18. sudo adduser erpnext
    sudo usermod -aG wheel erpnext
    sudo passwd erpnext

    sudo su erpnext
    cd ~
    wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py

    #sudo python install.py –develop –user erpnext
    sudo python install.py –production –site [site name].[domain] –user erpnext \
    –bench-name erpnext-prd –verbose 2>&1 | tee –append erpnext-install.log

    cd ~/frappe-bench
    sudo bench config dns_multitenant on
    mv sites/site1.local sites/erpnext.centrelinetechnologies.com
    bench setup nginx
    #sudo service nginx reload

    sudo bench setup production clerpnext
    bench update
    =====================================================
    install letsencrypt
    easy (but good luck if that works)
    sudo bench lets-encrypt

    sudo firewall-cmd –permanent –zone=public –add-service=http
    sudo firewall-cmd –permanent –zone=public –add-service=https
    sudo firewall-cmd –reload

    ========================================
    To survive a system reboot
    sudo systemctl enable supervisord
    sudo systemctl enable nginx

  19. ##########################################################
    sudo yum install wget
    sudo yum update
    sudo adduser clerpnext
    sudo usermod -aG wheel clerpnext
    sudo passwd clerpnext

    #######################################
    sudo firewall-cmd –permanent –zone=public –add-service=http
    sudo firewall-cmd –permanent –zone=public –add-service=https
    sudo firewall-cmd –reload

    ##########################################################

    sudo su clerpnext
    cd ~
    wget https://raw.githubusercontent.com/frappe/bench/master/playbooks/install.py

    #sudo python install.py –develop –user clerpnext
    sudo python install.py –production –user clerpnext

    cd ~/frappe-bench
    sudo bench config dns_multitenant on

    bench new-site erpnext.landingonmars.com
    bench –site erpnext.landingonmars.com install-app erpnext

    sudo bench setup production clerpnext
    bench update

    ####################################################=
    # install letsencrypt
    # easy (but good luck if that works)
    sudo bench setup lets-encrypt

    ########################################
    # To start after a system reboot
    sudo systemctl enable supervisord
    sudo systemctl enable nginx

    ##################################################################
    # Install second bench to do the experiments and install development versions

    sudo su clerpnext
    cd ~
    bench init dev-frappe-bench

    ##################
    # This was giving me grief with some python errors so below command fixed it
    sudo pip install –upgrade virtualenv –force
    sudo pip install –upgrade pip –force
    # (uninstalling and installing virtualenv and pip might help too)

    ##################

    cd ~/dev-frappe-bench
    sudo bench config dns_multitenant on
    bench new-site deverpnext.landingonmars.com
    MySQL rood password: *******
    .
    .

    bench get-app erpnext
    bench switch-to-develop
    bench update –patch

    bench –site deverpnext.landingonmars.com install-app erpnext

    ####################
    # install ssl certificates
    cd ~/dev-frappe-bench
    sudo bench setup lets-encrypt deverpnext.landingonmars.com

    # if that doesn’t work then do this

    sudo certbot –nginx -d deverpnext.landingonmars.com
    bench set-ssl-certificate deverpnext.landingonmars.com /etc/letsencrypt/live/deverpnext.landingonmars.com/fullchain.pem
    bench set-ssl-key deverpnext.landingonmars.com /etc/letsencrypt/live/deverpnext.landingonmars.com/privkey.pem

    sudo bench setup production clerpnext

    ################################
    # backup production site and restore it to development site for full comparision

    # backup production site
    cd ~/frappe-bench
    bench backup –with-files

    # restore to development site
    cd ~/dev-frappe-bench
    bench –force restore \
    –with-public-files /home/clerpnext/frappe-bench/sites/erpnext.landingonmars.com/private/backups/20190703_131146-erpnext_landingonmars_com-files.tar \
    –with-private-files /home/clerpnext/frappe-bench/sites/erpnext.landingonmars.com/private/backups/20190703_131146-erpnext_landingonmars_com-private-files.tar \
    /home/clerpnext/frappe-bench/sites/erpnext.landingonmars.com/private/backups/20190703_131146-erpnext_landingonmars_com-database.sql

    # All passwords and stuff are created with encryption key mentioned in the site_config.json file.
    # for them to work in new site, copy the same encryption key from the origin site to the destination.
    cat /home/clerpnext/frappe-bench/sites/erpnext.landingonmars.com/site_config.json
    # copy the encryption key value to the file below
    vim /home/clerpnext/dev-frappe-bench/sites/deverpnext.landingonmars.com/site_config.json
    # paste encryption key

    bench migrate
    bench clear-cache
    bench clear-website-cache
    bench restart

    ##########################################################
    # Install a site with demo information in it
    cd ~/dev-frappe-bench
    bench new-site devdemo.landingonmars.com
    bench –site devdemo.landingonmars.com install-app erpnext
    bench –site devdemo.landingonmars.com make-demo –reinstall

  20. hello saeed,
    im having a trouble installing erpnext there was and error when i enter command

    sudo python3 install.py –production –version 12 –user erpnext

    i follow your step but im not succesfull installing it.
    this is the error:

    [WARNING]: Module did not set no_log for update_password
    Traceback (most recent call last):
    File “install.py”, line 440, in
    install_bench(args)
    File “install.py”, line 241, in install_bench
    run_playbook(‘site.yml’, sudo=True, extra_vars=extra_vars)
    File “install.py”, line 365, in run_playbook
    success = subprocess.check_call(args, cwd=playbooks_folder, stdout=log_stream, stderr=sys.stderr)
    File “/usr/lib64/python3.6/subprocess.py”, line 311, in check_call
    raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘@/tmp/extra_vars.json’, ‘–become’, ‘–become-user=erpnext’]’ returned non-zero exit status 2.

    can you help me with this

Leave a Comment

Your email address will not be published. Required fields are marked *

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