Installing Frappe Framework v15 in Ubuntu: Including Production Setup

Guide to Install Frappe v15 in Ubuntu 22.04 LTS

 · 2 min read

Guide to Install Frappe Framework version 15 in Ubuntu 22.04 LTS


Follow these steps to ensure a successful installation of Frappe Version 15 on your Ubuntu 22.04 LTS system.


1. Prepare System Dependencies:


Install essential software for managing repositories:


sudo apt install software-properties-common


2. Python Installation:

Add the deadsnakes PPA for Python:

sudo add-apt-repository ppa:deadsnakes/ppa -y
sudo apt update


Install Python 3.11:

sudo apt install python3.11

Check if it is installed properly

python3.11 --version


Get the full Python 3.11 package:

sudo apt install python3.11-full


Install additional development tools:

sudo apt-get install python3-dev python3-setuptools python3-pip python3.11-venv
sudo apt-get update
sudo apt-get install -y build-essential python3.11-dev gcc
sudo apt-get install -y libffi-dev libssl-dev


3. Database Setup (MariaDB):

Install MariaDB server:

sudo apt install mariadb-server


Secure your MariaDB installation:

sudo mysql_secure_installation


Install necessary MySQL database development files:

sudo apt-get install libmysqlclient-dev


Configure MariaDB settings:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf


use this in the 50-server.cnf file

[server]
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

[mysqld]
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      
[mysql]
default-character-set = utf8mb4


Restart MariaDB:

sudo service mysql restart


4. Redis Installation:

Install Redis server:

sudo apt-get install redis-server

5. Node.js and Yarn Setup:

Install Node Version Manager (nvm):

sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.profile

Install Node.js 18.X

nvm install 18


Install Yarn:

sudo apt-get install npm
sudo npm install -g yarn


6. wkhtmltopdf installation

Install wkhtmltopdf dependencies:

sudo apt-get install xvfb libfontconfig wkhtmltopdf


[Optional]: Setting Up Production Environment

To isolate the Frappe setup in a dedicated user environment:

[Optional]:Create a New User:

sudo adduser frappe-user
sudo usermod -aG sudo frappe-user
su - frappe-user

You'll switch to the newly created user "frappe-user" to perform the following steps.


7. Frappe Installation:

Install Frappe Bench using pip3:

sudo -H pip3 install frappe-bench

Check the installed Bench version:

bench --version


8. Initialize Frappe Bench and Install Frappe Version 15:

Initialize the Frappe Bench with Python 3.11:

bench init frappe-bench --frappe-branch version-15 --python python3.11


After completing the installation, navigate to the frappe-bench directory and create sites and apps..


[Optional]Setup Production:

Configure Frappe Bench for production use:

sudo bench setup production frappe-user
bench restart

Open a web browser and navigate to the server's IP address to access the production instance.


Fix for supervisor

bench setup socketio
bench setup supervisor
bench setup redis
sudo supervisorctl reload


bench restart


Fix for css

sudo chmod -R o+rx /home/frappe-user

Aikyam Fellows Blog

Learn more about Aikyam Fellows


Jinso Raj

Fellow at t4glabs

Add a comment
Ctrl+Enter to add comment

J
Joe 4 months ago

Followed instructions and it is not working. Using Oracle cloud Ubuntu server.

frappe-user@erpnext:~/frappe-bench$ sudo bench setup production frappe-user bench restart [sudo] password for frappe-user: Setting Up prerequisites... $ bench setup role fail2ban ansible-playbook [core 2.17.1] config file = None configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.10/dist-packages/ansible ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible-playbook python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3) jinja version = 3.1.4 libyaml = True No config file found; using defaults setting up inventory plugins Loading collection ansible.builtin from hostlist declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method Skipping due to inventory source not existing or not being readable by the current user script declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method auto declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method Skipping due to inventory source not existing or not being readable by the current user yaml declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method Skipping due to inventory source not existing or not being readable by the current user ini declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method Skipping due to inventory source not existing or not being readable by the current user toml declined parsing /etc/ansible/hosts as it did not pass its verifyfile() method ERROR! [DEPRECATED]: ansible.builtin.include has been removed. Use includetasks or import_tasks instead. This feature was removed from ansible-core in a release after 2023-05-16. Please update your playbooks.

The error appears to be in '/usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/mariadb/tasks/main.yml': line 2, column 3, but may be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  • include: centos.yml ^ here ERROR: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "adminemails": "", "mysqlrootpassword": null, "container": false}', '-t', 'fail2ban']' returned non-zero exit status 1. Traceback (most recent call last): File "/usr/local/bin/bench", line 8, in <module> sys.exit(cli()) File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli benchcommand() File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in call return self.main(args, *kwargs) File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke return processresult(subctx.command.invoke(subctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke return processresult(subctx.command.invoke(subctx)) File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, *ctx.params) File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke return callback(args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 370, in setuproles runplaybook("site.yml", extravars=extravars, tag=role) File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 345, in runplaybook subprocess.checkcall(args, cwd=os.path.join(bench.path_[0], "playbooks")) File "/usr/lib/python3.10/subprocess.py", line 369, in checkcall raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '{"production": true, "adminemails": "", "mysqlroot_password": null, "container": false}', '-t', 'fail2ban']' returned non-zero exit status 1. ERROR: bench setup role fail2ban subprocess.CalledProcessError: Command 'bench setup role fail2ban' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/bin/bench", line 8, in <module> sys.exit(cli()) File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli benchcommand() File "/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py", line 110, in setupproduction setupproduction(user=user, yes=yes) File "/usr/local/lib/python3.10/dist-packages/bench/config/productionsetup.py", line 37, in setupproduction setupproductionprerequisites() File "/usr/local/lib/python3.10/dist-packages/bench/config/productionsetup.py", line 28, in setupproductionprerequisites execcmd("bench setup role fail2ban") File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 178, in execcmd raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd) bench.exceptions.CommandFailedError: bench setup role fail2ban

$ sudo supervisorctl restart frappe: frappe: ERROR (no such group) frappe: ERROR (no such group) ERROR: sudo supervisorctl restart frappe: subprocess.CalledProcessError: Command 'sudo supervisorctl restart frappe:' returned non-zero exit status 2.

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/bin/bench", line 8, in <module> sys.exit(cli()) File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli benchcommand() File "/usr/local/lib/python3.10/dist-packages/bench/commands/utils.py", line 41, in restart Bench(".").reload(web, supervisor, systemd) File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapperfn return fn(args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 152, in reload restartsupervisorprocesses(benchpath=self.name, webworkers=web, raise=raise) File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 342, in restartsupervisorprocesses failure = bench.run(f"{sudo}supervisorctl restart {group}", raise=raise) File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 48, in run return execcmd(cmd, cwd=cwd or self.cwd, _raise=raise) File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 178, in execcmd raise CommandFailedError(cmd) from subprocess.CalledProcessError(returncode, cmd) bench.exceptions.CommandFailedError: sudo supervisorctl restart frappe: