Deploying a Frappe (ERPNext) instance on a DigitalOcean droplet
Nayan Patel
February 25, 2023 - 5 min read
In this tutorial, I will outline how to create a Frappe (ERPNext) instance on a DigitalOcean droplet.
- To start, we will carry out the updates that are needed on the Droplet.
sudo apt-get update -y
sudo apt-get upgrade -y
If any popups show, just press enter to select the deafult option.
- Next, we will create a new sudo user, called
frappe
. This user will house our Frappe instance.
sudo adduser frappe
Set a password for the frappe user, and remember it. You will need to set the first name for this user aswell.
- Add the user to the sudo group, by carry out the following command
sudo adduser frappe sudo
- Now, we will switch to the
frappe
user.
su frappe
If you get a message, run the command again and you should be prompted for a password.
- Now we will navigate to the
frappe
users home directory by running the command:
cd /home/frappe
- We will install git on the Droplet.
sudo apt-get install git
- We will now install Python Dev.
sudo apt-get install python3-dev
When prompted, type Y
.
- We will install Setup tools and PIP.
sudo apt-get install python3-setuptools python3-pip
- We will install VirtualENV.
sudo apt-get install virtualenv
sudo apt install python3.10-venv
- We will install MariaDB.
sudo apt-get install software-properties-common
Next, run
sudo apt install mariadb-server
Next,
sudo mysql_secure_installation
Follow all instructions, and choose Y for all options.
- We will install MySQL now.
sudo apt-get install libmysqlclient-dev
- Edit the MariaDB Confiruration File.
You will see a [server]
text at the top, under that, put:
user = mysql
pid-file = /run/mysqld/mysqld.pid
socket = /run/mysqld/mysqld.sock
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
bind-address = 127.0.0.1
query_cache_size = 16M
log_error = /var/log/mysql/error.log
Under that, you will see a [mysqld]
. Under that, type:
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
It should look like this:
Finally, head to the bottom of the file and add the following lines:
[mysql]
default-character-set = utf8mb4
Hold Ctrl + X
to exit, then click Y
to save, then Enter
to get back to the console.
- Restart the MySQL server.
sudo service mysql restart
- Set git PATH.
export PATH=$PATH:/usr/bin/git
- Edit the MySQL config file.
sudo nano /etc/mysql/my.cnf
Add the following lines to the bottom of the file.
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql]
default-character-set = utf8mb4
Next, restart the service.
service mysql restart
- Install the redis server.
sudo apt-get install redis-server
- Install Node.
sudo apt install curl
After that, run:
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Then,
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Next run,
source ~/.profile
Finally, run:
nvm install 16.15.0
- Install Yarn.
sudo apt-get install npm
After that, run:
sudo npm install -g yarn
- Install wkhtmltopdf.
sudo apt-get install xvfb libfontconfig wkhtmltopdf
This will take a while.
- Restart the server.
sudo reboot
Reboot the server, wait 5 minutes, then try to reconnect to it.
Log in with the frappe
user that we created.
- Install Frappe Bench.
sudo pip3 install frappe-bench
Ignore the warning.
Confirm it's installed by running:
bench --version
- Initialise the Bench.
bench init frappe-bench --frappe-branch version-14
This will take a while.
cd frappe-bench/
bench start
If you now load to the site at IP:8000
you should see a RuntimeError. This is because we haven't created a site.
- Create a site.
Open a new SSH terminal and log in.
Get back into the frappe-bench directory.
cd frappe-bench/
bench new-site <yourdomain>.com
bench use <yourdomain>.com
- Restart the server.
sudo reboot
- Log back into the server.
Log into the server with the frappe user, and navigate to the Frappe Bench folder.
cd frappe-bench/
Start the server.
bench start
- Access the site
Access the site at IP:8000
. If the styles look off, click Ctrl + C
in the terminal to close the bench, then type the command:
bench build
then
bench start
- If you now access the site at
IP:8000
, you should be able to see the site and the assets.
To log in, the username is Administrator
and the password that you set.
To add SSL, Custom Domain, or change to production mode, please see the other articles.