📡 Part 1: Setup and Configure a Remote MariaDB Server
MariaDB is the preferred database for ERPNext, and hosting it remotely allows better scalability and security in production environments.
🔧 Step 1: Install MariaDB Server and Client
$ sudo apt update
$ sudo apt install mariadb-server mariadb-client -y
$ mysql_secure_installation
The mysql_secure_installation script helps you remove insecure default settings like anonymous users, test databases, and allows setting the root password.
🛠 Step 2: Configure MariaDB for Remote Access
Open the MariaDB server configuration , Update the bind-address:
$ sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf save and exit
bind-address = 0.0.0.0
:wq!
This allows MariaDB to accept connections from any IP address. Be sure your firewall or cloud security groups allow port 3306.
Then, update character sets for compatibility:
$ sudo vim /etc/mysql/my.cnf
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
[mysql] save and exit
default-character-set = utf8mb4
:wq!
🔐 Step 3: Create Remote Access for Root
Log in to MySQL:
$ mysql -u root -p
> GRANT ALL PRIVILEGES ON *.* TO 'root'@'frappe_server_ip' IDENTIFIED BY 'YOUR_PASSWORD' WITH GRANT OPTION;
> FLUSH PRIVILEGES;
> EXIT;
Replace frappe_server_ip with the actual IP address of your Frappe server.
🔄 Step 4: Restart MariaDB
$ sudo systemctl restart mariadb
🖥 Part 2: Setup the Frappe Server to connect remote DB
👤 Step 1: Create a Frappe User and Install Dependencies
# apt update
# adduser frappe
# usermod -aG sudo frappe
# su - frappe
Install essential packages:
$ sudo apt install git python-is-python3 python3-dev python3-pip redis-server \
libmariadb-dev mariadb-client pkg-config python3.12-venv xvfb libfontconfig \
certbot python3-certbot-nginx -y
🧰 Step 2: Setup Node.js, Yarn, and wkhtmltopdf
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
$ source ~/.profile
$ nvm install 23
$ node -v
$ npm install -g yarn
$ npm install -g npm@11.4.2
Install wkhtmltopdf (used for PDF reports in ERPNext):
$ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb
$ sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb
$ sudo apt install -f -y
🐍 Step 3: Create Python Virtual Environment and Install Frappe Bench
$ python3 -m venv myenv
$ source myenv/bin/activate
$ pip3 install frappe-bench
$ bench --version
Initialize the bench:
$ bench init --frappe-branch version-15 frappe-bench
$ cd frappe-bench/
$ chmod -R o+rx /home/frappe/
🌐 Step 4: Connect Remote Database
$ pip3 install ansible
$ bench set-mariadb-host <db_server_ip>
Install Ansible and set remote DB host, replace db_server_ip with ip address of mariadb server
Create a new site:
$ bench new-site frappe-erpnext.yoursite.in
$ bench --site frappe-erpnext.yoursite.in add-to-hosts
check with the remote DB server , db of the above site will be created
📦 Step 5: Install ERPNext App
$ bench get-app --branch v15.67.0 https://github.com/frappe/erpnext.git
$ bench --site frappe-erpnext.yoursite.in install-app erpnext
$ bench --site frappe-erpnext.yoursite.in enable-scheduler
$ bench --site frappe-erpnext.yoursite.in set-maintenance-mode off
⚙️ Step 6: Setup Production
$ bench setup env --python PATH="$PATH"
$ sudo -E env PATH="$PATH" bench setup sudoers $(whoami)
$ sudo -E env PATH="$PATH" bench setup production frappe
$ sudo systemctl reload nginx
Configure NGINX and Supervisor:
bench setup nginx
$ sudo supervisorctl restart all
$ sudo -E env PATH="$PATH" bench setup production frappe
$ sudo systemctl reload nginx
$ sudo supervisorctl restart all
Set up HTTPS with Let’s Encrypt:
$ sudo certbot --nginx

0 Comments