EDIT 12-22-2021 BKM
Edited the text of the procedure to include a check for the supervisor.conf file. At some point in the past 2 weeks, this Tutorial was not producing a complete system. Something changed and the supervisor.conf file was no longer being dropped into the proper directory to allow the system to boot to a login screen. this meant that you could not run the startup wizard with the first login of the Administrator. While I was not able to track down the source of the problem yet, I have included a few additional steps before enabling the scheduler to check for this error and fix it before completing the install. The procedure begins below. Hope this helps.
Here is how to do this manually. It is not the ONLY way to do it and this method does have some peculiar things about it (like installing bench twice) but it works and it works very well. You also do not get the bench editable mode messages with this method.
One more thing to note before you start. You may have heard all kinds of things about having to rename the bench and renaming site directories to make your URLs work, etc. Well, this install method, if followed exactly, produces nearly an identical installation as you would have done using the old Easy Install script. That means that you will be using bench commands to define your sites and not brute force renaming of directories and other nonsense. This method really simplifies everything. So, now go ahead and get started.
Read every line carefully. Don’t skip any steps!
Anywhere that you see [USER] you need to insert your server user name.
-
Choose any cloud you trust
-
Login to your system via ssh with root user (I use putty client for this)
-
apt update && apt upgrade -y && shutdown -r now
-
Log back in as root user again then type the following commands:
apt-get install curl git
apt-get install sudo
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
-
Now we install all of the prerequisites for a functioning server:
apt install -y nodejs mariadb-server redis-server python3-pip nginx python3-testresources python3-distutils python3-setuptools python3.8-venv libssl-dev wkhtmltopdf
- Now add the user to serve as the home directory for the ERPNext install:
adduser [USER]
usermod -aG sudo [USER]
- Now we need to edit the MySQL config file:
nano /etc/mysql/my.cnf
When the editor opens scroll to the bollom of the file and add these lines:
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
-
Now we need to restart mysql:
service mysql restart
-
Here we setup mysql (mariadb) to operate properly:
mysql_secure_installation
(press the enter key for password then answer the questions as follows)
Set root password? [Y/n] y
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y -
To complete the mysql setup do the following:
mysql -u root -p[your-password-here]
Immediately after the -p type the password you assigned to mariadb in the last step. Remember there is to be NO space between the -p and the first character of the password. Then at the database prompt type the following commands (case sensitive & press enter after each line)
USE mysql;
UPDATE user SET plugin=' ' WHERE user = 'root';
FLUSH PRIVILEGES;
exit
-
Close the terminal window (logout of root) and open a new one with ssh [USER] and execute the following commands:
sudo npm install -g yarn
pip3 install frappe-bench
export PATH=$PATH:/home/[USER]/.local/bin
sudo pip3 install frappe-bench
bench init --frappe-branch version-13 frappe-bench
cd frappe-bench
bench new-site site1.local
bench get-app --branch version-13 erpnext
bench --site site1.local install-app erpnext
sudo bench setup production [USER]
Now, due to recent problems it is important to check for the existence of an important configuration file. Execute the following command:
sudo ls /etc/supervisor/conf.d
If supervisor.conf
is listed as a file here, then you can skip to the ‘enable scheduler’ step below. However, If there are no files listed then the supervisor.conf
file was not transferred properly. To fix this perform the following command:
sudo cp ~/frappe-bench/config/supervisor.conf /etc/supervisor/conf.d/supervisor.conf
This should fix the problem of not being able to get to the login screen. You can now finish the rest of the install.
bench --site site1.local enable-scheduler
-
Now reboot the server. Once it has rebooted you should be able to open a web browser and type in the ip address of your server to get the ERPNext login screen. Login as administrator and go through the setup wizard before attempting to do any further work on the server. Once that is done come back to this point to continue setting up your URL and your SSL certificate (very simple to do)!
-
Once you have complete the Administrator setup wizard, log out of ERPNext and open a fresh SSH window and login as [USER] then execute the following to add your URL to your ERPNext Server installation:
export LC_ALL=C.UTF-8
cd frappe-bench
bench config dns_multitenant on
bench setup add-domain --site site1.local [your.new.URL]
bench setup nginx
(answer Y to the question about replacing the config file)
sudo service nginx restart
cd ~
-
Now it is time to work on the SSL certificate for your server. First we need to make sure that certbot is not already installed:
sudo apt-get remove certbot
-
Now we are going to install the package bundle provider and make sure it is all up to date with the latest release of ‘snapd’ and let it handle the certbot for us (much simpler this way):
sudo apt install snapd
sudo snap install core
sudo snap refresh core
-
Now we use the ‘snap’ service to automatically install and configure certbot to work properly with your new ERPNext server:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
-
Now we can safely use the pre-configured certbot to install your SSL certificate:
sudo certbot --nginx
(The system will pause at some point and ask you to select the site name you wish to install the certificate from a list of names it found. Be sure to select the URL you used and not ‘site1.local’ at this point) -
Once this is done, you can close your ssh client, open a browser and type the URL of your server into the address bar and it should take you to the secured version of your ERPNext server.
-
One final note here. This method specifically does NOT rename bench or the site directories in order to provide flexibility later in the event you need to have multiple URL’s pointing to the same instance of ERPNext or if you need to change your URL for some reason in the future. Using the
bench setup add-domain
command makes this much simpler. The SSL certificate instructions I provided above are tailored to support this configuration.
Hope this helps, but as always…
Your mileage may vary
BKM