This guide will guide you through installing Frappe and ERPNext on your Ubuntu system. It's broken down into several steps, each with clear instructions and explanations.
Before you begin, ensure your Ubuntu system meets these prerequisites:
- Python: Version 3.6 or later
- Node.js: Version 14 or later
- Redis: Version 5
- MariaDB: Version 10.3.x (or PostgreSQL 9.5.x)
- Yarn: Version 1.12 or later
- Pip: Version 20 or later
- wkhtmltopdf: Version 0.12.5 (with patched Qt) for PDF generation
- Cron: For automated tasks like certificate renewals and backups
- Nginx: For proxying multi-tenant sites in production
Install Git, a powerful version control system:
sudo apt-get install git
Install python-dev
for compiling Python C extensions:
sudo apt-get install python3-dev
Install setuptools
and pip
, Python's package managers:
sudo apt-get install python3-setuptools python3-pip
Install virtualenv
to create isolated Python environments:
sudo apt-get install virtualenv
Check your Python version:
python3 -V
If your version is 3.8.x, run:
sudo apt install python3.8-venv
If your version is 3.10.x, run:
sudo apt install python3.10-venv
MariaDB is a powerful open-source relational database management system:
-
Download MariaDB repository: Visit https://downloads.mariadb.org/mariadb/repositories/#mirror=piconets
-
For Ubuntu 20.04:
sudo apt-get install software-properties-common sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://ftp.icm.edu.pl/pub/unix/database/mariadb/repo/10.3/ubuntu focal main' sudo apt update sudo apt install mariadb-server
-
For Ubuntu 18.04:
sudo apt-get install software-properties-common dirmngr apt-transport-https sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirrors.aliyun.com/mariadb/repo/10.3/ubuntu bionic main' sudo apt update sudo apt install mariadb-server
Important: You will be prompted to set the MySQL root password during installation. If you don't see this prompt, you can manually initialize MariaDB using:
sudo mysql_secure_installation
if have error on connection with mysql root go to step Changing the MySQL Root Password
sudo apt-get install libmysqlclient-dev
if you don't have nano
sudo apt install nano
-
Edit the MariaDB configuration file:
sudo nano /etc/mysql/my.cnf
-
Add the following lines:
[mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci [mysql] default-character-set = utf8mb4
-
Save the file (Ctrl+X, Y, Enter).
-
Restart the MariaDB service:
sudo service mysql restart
Redis is a high-performance in-memory data store used for caching and real-time updates:
sudo apt-get install redis-server
Node.js is a JavaScript runtime environment used for server-side development:
sudo apt-get install curl
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
Yarn is a package manager for JavaScript projects:
sudo npm install -g yarn
If you encounter errors, try these steps:
sudo npm uninstall -g yarn
sudo rm -rf /usr/bin/yarn
wkhtmltopdf converts HTML pages to PDFs:
sudo apt-get install xvfb libfontconfig wkhtmltopdf
For a server environment:
pip3 install frappe-bench
For local development:
sudo -H pip3 install frappe-bench
Important: After installing frappe-bench
, log out and log back into your terminal before proceeding.
Verify the installation:
bench --version
-
Create a directory for your Frappe installation:
mkdir frappe-bench cd frappe-bench
-
Initialize the Frappe bench:
bench init frappe-bench --frappe-branch version-15
(Replace
version-15
with the desired Frappe version if necessary) -
Start the bench:
bench start
bench new-site dcode.com
-
Get the ERPNext application:
bench get-app erpnext --branch version-15
Or, from a specific GitHub repository:
bench get-app https://github.com/frappe/erpnext --branch version-15
-
Install ERPNext on your site:
bench --site dcode.com install-app erpnext
-
Start the bench:
bench start
This step is only necessary for production server setups.
-
Create a new user:
sudo adduser dcode-frappe sudo usermod -aG sudo dcode-frappe su - dcode-frappe python3 -m venv /path/to/my_env source /path/to/my_env/bin/activate
-
Follow steps 12 to 15.
-
Set up production:
sudo bench setup production dcode-frappe bench restart
-
Open the server IP in your web browser: You can now access your production server.
-
Switch off DNS-based multitenancy:
bench config dns_multitenant off
-
Create a new site:
bench new-site site2name
-
Set a port for the new site:
bench set-nginx-port site2name 82
-
Regenerate the Nginx configuration:
bench setup nginx
-
Reload Nginx and Supervisor:
sudo service nginx reload sudo service supervisor restart
-
Obtain a Let's Encrypt certificate for your site:
sudo add-apt-repository ppa:certbot/certbot sudo apt update sudo apt install python-certbot-nginx sudo certbot --nginx -d example.com
-
Install the Frappe application locally:
./env/bin/python -m pip install -q -U -e /apps/frappe
-
Stop production services and start in development mode:
sudo service supervisor stop sudo service redis stop sudo service nginx stop
-
Start development mode (ensure you have a
Procfile
in thefrappe-bench
directory):bench setup procfile bench start
-
Restart production mode:
sudo service supervisor start sudo service redis start sudo service nginx start
-
Check the status of services:
sudo service supervisor status sudo service redis status sudo service nginx status
-
Connect to MySQL:
sudo mysql -u root -p
-
Create the new user:
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON * . * TO 'new_user'@'localhost'; FLUSH PRIVILEGES;
-
Grant all privileges to the
admin
user:grant all on *.* to 'admin@localhost' identified by 'admin' with grant option;
-
Set the
root
user password:SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mypass');
-
Enable DNS-based multitenancy:
bench config dns_multitenant on
-
Set the site name in
sites/currentsite.txt
:nano sites/currentsite.txt
Write "banna.com" in the file.
-
MariaDB:
sudo service mysql restart
-
Redis:
sudo service redis-server {start|stop|restart|force-reload|status}
-
Configure Redis port (in
/etc/redis/redis.conf
):- Change the port number to 11000 and comment out the original port 6379.
- Test the new port:
redis-cli -h localhost -p 11001 ping
-
Supervisor:
sudo nano /etc/supervisor/supervisord.conf chown= yourfrappeusername:yourfrappeusername sudo -A systemctl restart supervisor
-
Supervisor:
sudo apt -y install supervisor bench setup supervisor sudo ln -s pwd/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
-
Nginx:
sudo apt -y install nginx bench setup nginx sudo ln -s pwd/config/nginx.conf /etc/nginx/conf.d/frappe-bench.conf
sudo nano /etc/hosts
Add the following line:
127.0.0.1 frappe.localhost
bench new-site --db-name [] --db-password [] --db-type mariadb --db-host 127.0.0.1 --db-port 3306 --mariadb-root-username root --mariadb-root-password [] --no-mariadb-socket --admin-password Admin --install-app erpnext [].cybererps.com
bench drop-site --mariadb-root-username admin@localhost --mariadb-root-password admin --force banna.com
-
Activate:
source env/bin/activate
-
Deactivate:
source env/bin/deactivate
bench --site library.test console
bench --site library.test mariadb
bench --site library.test backup
bench switch-to-branch version-15 frappe erpnext --upgrade
git pull upstream version-15
bench get-app --branch=version-15 frappe
bench add-frappe-ui
Set the following environment variables:
ERPNEXT_API_KEY = 'ad43b3e0a015a82'
ERPNEXT_API_SECRET = 'd550eb2103b2a9b'
ERPNEXT_URL = 'http://dev.local:8000'
ERPNEXT_VERSION = 15
bench --site frappe.localhost set-config ignore_csrf 1
-
Stop the MySQL service:
sudo systemctl stop mysql killall mysqld sudo nano /home/[username]/mysql-init # ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassword'; sudo mysqld --init-file=/home/[username]/mysql-init & sudo service mysql start
-
Start MySQL in safe mode:
sudo mysqld_safe --skip-grant-tables --skip-networking &
-
Connect to MySQL as the root user:
sudo mysql -u root
-
Update the root password:
USE mysql; UPDATE user SET authentication_string=PASSWORD('new_password') WHERE User='root'; FLUSH PRIVILEGES;
-
Exit MySQL:
EXIT;
-
Kill the safe mode process:
sudo killall mysqld_safe
-
Start the MySQL service:
sudo systemctl start mysql
sudo apt install net-tools
sudo netstat -tuln | grep '13000\|11000'
sudo lsof -i :13000
sudo kill 27381
- Replace placeholders like
[]
with your specific values. - Use the correct Frappe and ERPNext versions for your needs.
- Refer to the official Frappe and ERPNext documentation for more detailed instructions and troubleshooting guides.
- This guide provides a starting point for installation. Adapt the steps to suit your specific needs.
Good luck!