frappe installation tutorial , for
Ubuntu 22.04
frappe bench 5.24.1
frappe framework v15.66.1
update system
sudo apt update
sudo apt upgrade -y
install system dependencies
sudo apt install -y \
git \
python3.10 \
python3.10-dev \
python3.10-venv \
python3-pip \
pkg-config \
software-properties-common \
libfontconfig1 \
xvfb
install redis
sudo apt install redis-server
# do not start the redis server the bench script will start it on its own
install mariadb
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64] http://mirror.mariadb.org/repo/10.6/ubuntu jammy main'
sudo apt update
sudo apt install -y mariadb-server-10.6 mariadb-client-10.6 libmariadb-dev
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
sudo cp /etc/mysql/mariadb.conf.d/50-server.cnf /etc/mysql/mariadb.conf.d/50-server.cnf.bak
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
[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
sudo systemctl restart mariadb
install the pdf thing
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
sudo apt install -y ./wkhtmltox_0.12.6-1.focal_amd64.deb
wkhtmltopdf --version
install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 18.15.0
npm install -g yarn@1.22.19
install frappe
python3 -m pip install --upgrade pip==25.0.1
pip3 install frappe-bench==5.24.1
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
bench init frappe-bench --frappe-branch v15.66.1
create bench
bench new-app appname
bench new-site sub.domain.com
# make it exactly the same as your domain , do not use anything else (setup for a seperate name is different )
bench use sub.domain.com
bench --site sub.domain.com install-app appname
hear your bench start should start working , and all the other bench related commands
but for a production setup you need something that can run in the background
hence the below production setup , once you configure that bench start should stop working and bench restart should work
production
sudo apt -y install supervisor
sudo bench setup production <user name for linux>
sudo apt-get install supervisor
bench setup supervisor
sudo ln -s `pwd`/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl status
sudo nano /etc/supervisor/supervisord.conf
[unix_http_server]
file=/var/tmp/supervisord.sock
chmod=0700
chown=<user name for linux>:<user name for linux>
faced multiple problems with supervisor and nginx so uninstall script for nginx and supervisor
sudo systemctl stop supervisor
sudo apt-get purge supervisor
sudo rm -rf /etc/supervisor
sudo systemctl stop nginx
sudo apt-get purge nginx nginx-common nginx-full
sudo rm -rf /etc/nginx
sudo rm -rf /var/log/nginx
sudo rm -rf /var/www/html
sudo apt-get autoremove
sudo apt-get clean
also delete script for deleting database when faced problems with app
sudo mysql -u root -p
SHOW DATABASES;
DROP DATABASE _fb4b895ec24305ae;
nginx config
upstream frappe-bench-frappe {
server 127.0.0.1:8000 fail_timeout=0;
}
upstream frappe-bench-socketio-server {
server 127.0.0.1:9000 fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
server_name
erpnext.gseven.in
;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name
erpnext.gseven.in
;
ssl_certificate /etc/ssl/wildcardssl/fullchain.pem;
ssl_certificate_key /etc/ssl/wildcardssl/privkey.pem;
root /home/i2k2-admin/frappe-bench/sites;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
add_header X-Frame-Options "SAMEORIGIN";
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header Referrer-Policy "same-origin, strict-origin-when-cross-origin";
location /assets {
try_files $uri =404;
add_header Cache-Control "max-age=31536000";
}
location ~ ^/protected/(.*) {
internal;
try_files /erpnext.gseven.in/$1 =404;
}
location /socket.io {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Frappe-Site-Name erpnext.gseven.in;
proxy_set_header Origin $scheme://$http_host;
proxy_set_header Host $host;
proxy_pass http://frappe-bench-socketio-server;
}
location / {
rewrite ^(.+)/$ $1 permanent;
rewrite ^(.+)/index\.html$ $1 permanent;
rewrite ^(.+)\.html$ $1 permanent;
location ~* ^/files/.*.(htm|html|svg|xml) {
add_header Content-disposition "attachment";
try_files /erpnext.gseven.in/public/$uri @webserver;
}
try_files /erpnext.gseven.in/public/$uri @webserver;
}
location @webserver {
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frappe-Site-Name erpnext.gseven.in;
proxy_set_header Host $host;
proxy_set_header X-Use-X-Accel-Redirect True;
proxy_read_timeout 120;
proxy_redirect off;
proxy_pass http://frappe-bench-frappe;
}
# error pages
error_page 502 /502.html;
location /502.html {
root /home/i2k2-admin/.local/lib/python3.10/site-packages/bench/config/templates;
internal;
}
#access_log /var/log/nginx/access.log main;
#error_log /var/log/nginx/error.log;
# optimizations
sendfile on;
keepalive_timeout 15;
client_max_body_size 50m;
client_body_buffer_size 16K;
client_header_buffer_size 1k;
# enable gzip compresion
# based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
gzip on;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/font-woff
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component
;
# text/html is always compressed by HttpGzipModule
}