Centos 7 ERPNext Easy Install fix
How to install ERPNext on Centos 7
Definitely we will show how to install erpnext on Centos 7 on a VPS.
This should be really easy as per git info :https://github.com/frappe/bench#easy-install-script But for sure you may face many issues so we will show how to handle them easily.
Create user frappe and add to a wheel group first. If you on Centos mininal you'll require packages that may be already installed on non-mininal setup.
yum install sudo which nano
reLogin under user frappe and act via sudo.
su - frappe
Edit env:
nano /etc/environment LANG=en_US.utf-8 LC_ALL=en_US.utf-8
Edit locale:
nano /etc/locale.conf LC_ALL=en_US.utf-8 LC_CTYPE=en_US.utf-8 LANG=en_US.utf-8 LC_COLLATE="C" #LANG=C
Relogin!
exit su - frappe
Install depencies:
sudo yum groupinstall "Devevlopment Tools" sudo yum install python3 python3-devel python3-wheel ansible
Install nodejs:
sudo curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - sudo yum install nodejs #check: node -v v10.21.0
Run EasySetup sctipt. Please note during easy setup script you may also face issues. Using --verbose will show you more details - you'll be able to view in details which exactly ansible playbook caused an issue and fix/edit or remove part of playbook in order to skip error and handle it manually.
sudo python3 install.py --production --site erp.domain.com --user frappe --verbose --container
I'll provide issues and troubleshoot experience/example:
First error I got about selinux policy even it was disabled on my vps so I've simply edited the corresponding book from the error:
nano /tmp/.bench/playbooks/roles/frappe_selinux/tasks/main.yml
remove lines regarding selinux policy commands and init so file looks like:
--- - name: Install deps yum: name: - policycoreutils-python - selinux-policy-devel state: present when: ansible_distribution == 'CentOS' ...
Restarted the easyinstall script and got the next issue:
TASK [bench : Create a new site] ********************************************************************************************** task path: /tmp/.bench/playbooks/roles/bench/tasks/setup_erpnext.yml:17 <127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root <127.0.0.1> EXEC /bin/sh -c 'echo ~root && sleep 0' <127.0.0.1> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /var/tmp `"&& mkdir /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419 && echo ansible- tmp-1592951572.4-31249-46029726533419="` echo /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419 `" ) && sleep 0' Using module file /usr/lib/python2.7/site-packages/ansible/modules/commands/command.py <127.0.0.1> PUT /root/.ansible/tmp/ansible-local-27698mrm95R/tmpeU0Goi TO /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419/AnsiballZ_command.py <127.0.0.1> EXEC /bin/sh -c 'setfacl -m u:frappe:r-x /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419/ /var/tmp/ansible-tmp-1592951572.4-31249- 46029726533419/AnsiballZ_command.py && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u frappe /bin/sh -c '"'"'echo BECOME-SUCCESS-csgzmunubmeoqogldsmljkmyudingcit ; /usr/bin/python2 /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419/AnsiballZ_command.py'"'"' && sleep 0' <127.0.0.1> EXEC /bin/sh -c 'rm -f -r /var/tmp/ansible-tmp-1592951572.4-31249-46029726533419/ > /dev/null 2>&1 && sleep 0' fatal: [localhost]: FAILED! => { "changed": true, "cmd": [ "bench", "new-site", "erp.domain.net", "--admin-password", "PASSWORD", "--mariadb-root-password", "DBPASSWORD" ], "delta": "0:00:02.269755", "end": "2020-06-23 18:32:54.889770", "invocation": { "module_args": { "_raw_params": "bench new-site erp.domain.net --admin-password 'PASSWORD' --mariadb-root-password 'DBPASSWORD'", "_uses_shell": false, </ommited>
Googling the error will point us that most likely there was no bench init issued. manually you can do it with cd /home/frappe/frappe-bench/&&bench init erp.example.net command . But we will add it to playbook.
- However please note that at this point erpnext is installed you may continue manual action to add site and generate nginx config
So modify corresponding playbook File [from error]: /tmp/.bench/playbooks/roles/bench/tasks/setup_erpnext.yml and add Init Bench step:
--- - name: Check if ERPNext App exists stat: path="{{ bench_path }}/apps/erpnext" register: app - name: Get the ERPNext app command: bench get-app erpnext {{ erpnext_repo_url }} --branch {{ erpnext_branch }} args: creates: "{{ bench_path }}/apps/erpnext" chdir: "{{ bench_path }}" when: not app.stat.exists and not without_erpnext - name: Check whether the site already exists stat: path="{{ bench_path }}/sites/{{ site }}" register: site_folder - name: Init bench command: "bench init {{ site }}" args: chdir: "{{ bench_path }}" - name: Create a new site command: "bench new-site {{ site }} --admin-password '{{ admin_password }}' --mariadb-root-password '{{ mysql_root_passwor$ args: chdir: "{{ bench_path }}" when: not site_folder.stat.exists - name: Install ERPNext to default site command: "bench --site {{ site }} install-app erpnext" args: chdir: "{{ bench_path }}" when: not without_erpnext ...
OK relogin for any case and restar easyinstall:
cd /home/<whete install.py exisst> sudo python3 install.py --production --site erp.ikrok.net --user frappe --verbose --container
And we got failed on the supervisorctl playbook:
TASK [Restart the bench] ****************************************************************************************************** task path: /tmp/.bench/playbooks/roles/bench/tasks/setup_bench_production.yml:24 "stderr_lines": [], "stdout": "unix:///var/run/supervisor/supervisor.sock no such file\n\u001b[90m$ sudo supervisorctl restart frappe:\u001b[0m", "stdout_lines": [ "unix:///var/run/supervisor/supervisor.sock no such file", "\u001b[90m$ sudo supervisorctl restart frappe:\u001b[0m"
Ok. that's simple - just start supervisord service manually :
sudo systemctl start supervisord sudo systemctl status supervisord #should be ok. otherwise go to supervisord logs or check if it's installed and install if missed.
Check supervisord socket for any case:
sudo lsof -c supervisord | egrep 'COMMAND|sock' $output: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME superviso 9874 root mem REG 182,492801 83872 524594 /usr/lib64/python2.7/lib-dynload/_socketmodule.so superviso 9874 root 4u unix 0xffff881ff9d0a840 0t0 2609143405 /var/run/supervisor/supervisor.sock.9871 superviso 9874 root 37w REG 182,492801 21 39588217 /home/frappe/frappe-bench/logs/node-socketio.log superviso 9874 root 38w REG 182,492801 0 39588218 /home/frappe/frappe-bench/logs/node-socketio.error.log superviso 9874 root 52w REG 182,492801 2162 39588223 /home/frappe/frappe-bench/logs/redis-socketio.log superviso 9874 root 53w REG 182,492801 0 39588224 /home/frappe/frappe-bench/logs/redis-socketio.error.log
Ok, Restart EasyInstall once again:
sudo python3 install.py --production --site erp.ikrok.net --user frappe --verbose --container
Next we can face again SeLinux policy related error:
TASK [frappe_selinux : Check enabled SELinux modules] ************************************************************************* task path: /tmp/.bench/playbooks/roles/frappe_selinux/tasks/main.yml:10 fatal: [localhost]: FAILED! => { "changed": true, "cmd": "semanage module -l", "delta": "0:00:02.268645", "end": "2020-06-23 19:53:43.270595", "invocation": { "module_args": { "_raw_params": "semanage module -l", "_uses_shell": true, "argv": null, "chdir": null, "creates": null, "executable": null, "removes": null, "stdin": null, "stdin_add_newline": true, "strip_empty_ends": true, "warn": true } }, "msg": "non-zero return code", "rc": 1, "start": "2020-06-23 19:53:41.001950", "stderr": "ValueError: SELinux policy is not managed or store cannot be accessed.", "stderr_lines": [ "ValueError: SELinux policy is not managed or store cannot be accessed."
Remove all steps except - name: Install deps from /tmp/.bench/playbooks/roles/frappe_selinux/tasks/main.yml like we did it earlier Start easyinstall once again:
sudo python3 install.py --production --site erp.ikrok.net --user frappe --verbose --container
OK now erpnext in production mode installed using ansible playbooks from easyinstall.py script on Centos 7 .
Bench + Frappe + ERPNext has been successfully installed!
Check statuses:
sudo netstat -tulpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1204/sshd tcp 0 0 127.0.0.1:11000 0.0.0.0:* LISTEN 9881/redis-server 1 tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 26678/python3.6 tcp 0 0 127.0.0.1:12000 0.0.0.0:* LISTEN 9883/redis-server 1 tcp 0 0 127.0.0.1:13000 0.0.0.0:* LISTEN 9882/redis-server 1 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 26421/nginx: worker tcp6 0 0 :::22 :::* LISTEN 1204/sshd tcp6 0 0 :::9000 :::* LISTEN 26679/node tcp6 0 0 :::3306 :::* LISTEN 22355/mysqld
Check supervisorctl status:
sudo supervisorctl frappe-bench-redis:frappe-bench-redis-cache RUNNING pid 9882, uptime 0:16:44 frappe-bench-redis:frappe-bench-redis-queue RUNNING pid 9881, uptime 0:16:44 frappe-bench-redis:frappe-bench-redis-socketio RUNNING pid 9883, uptime 0:16:44 frappe-bench-web:frappe-bench-frappe-web RUNNING pid 26678, uptime 0:03:32 frappe-bench-web:frappe-bench-node-socketio RUNNING pid 26679, uptime 0:03:32 frappe-bench-workers:frappe-bench-frappe-default-worker-0 RUNNING pid 30103, uptime 0:00:02 frappe-bench-workers:frappe-bench-frappe-long-worker-0 STARTING frappe-bench-workers:frappe-bench-frappe-schedule STARTING frappe-bench-workers:frappe-bench-frappe-short-worker-0 STARTING
After that you'll probably note that /assets not loading on your ERPNext website and the site looks broken. You'll probably will require to rebuild bench in order to make /assets work; Here is how can we fix it:
supervisorctl stop all #go to frappe user su - frappe screen bench build bench restart
In case of any further issues you need to check logs
or start bench in debug:
supervisorctl stop all #go to frappe user su - frappe screen #or screen -R to reattach to existent screen bench start #you will se debug output
!!Please be carefull with the update!! -better check and test right after install as there may be differ banch issues or doctypes problems. use for update:
bench update #or bench update --reset #or bench update --patch
- troubleshoot:
Reload doctypes if failed on updates:
bench --force reload-doc core doctype communication_link bench --force reload-doc core doctype communication
- reinstall Site
You may reinstall the website if need: Make backup of your current config like:
mkdir /home/frappe/backups/ cp -avr /home/frappe/frappe-bench/sites/<your_site> /home/frappe/backups/ bench drop-site <your_site> bench install
Install manually from the bench init point. Go to frappe user
su - frappe #check that you are in home dir : pwd /home/frappe/
Init new bench :
sudo bench init my-bench %% cd my-bench
Add new site:
sudo bench new-site erp.domain.com
Install erp app:
sudo bench get-app erpnext https://github.com/frappe/erpnext sudo bench --site erp.domain.com install-app erpnext
Start for check:
sudo bench start
If ok stop and restart via supervisorctl
Setup for production use [assuming you have supervisor installed] :
sudo bench setup production bench ##install supervisor if need: #sudo yum -y install supervisor #sudo systemctl start supervisord #sudo systemctl enable supervisord
Check:
sudo supervisorctl status all
Enable DNS multy-tenancy in order to use with Let's Encrypt:
bench config dns_multitenant on sudo bench setup lets-encrypt erp.example.com bench enable-scheduler