Skip to content

Instantly share code, notes, and snippets.

@drthilina
Last active September 5, 2024 18:46
Show Gist options
  • Select an option

  • Save drthilina/d158032bed800c51f94a0e2db4267adf to your computer and use it in GitHub Desktop.

Select an option

Save drthilina/d158032bed800c51f94a0e2db4267adf to your computer and use it in GitHub Desktop.

Revisions

  1. drthilina revised this gist Sep 29, 2023. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions 1_erpnext13_public.sh
    Original file line number Diff line number Diff line change
    @@ -223,8 +223,4 @@ $ bench setup nginx
    $ sudo systemctl restart nginx

    # For good measure
    $ sudo reboot now



    whats remaining is securing the SSH connection and setting up UFW.
    $ sudo reboot now
  2. drthilina renamed this gist Sep 29, 2023. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. drthilina revised this gist Sep 29, 2023. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,9 @@ $ nano /etc/mysql/my.cnf

    # This will open mariadb main config file, add the following to end
    [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
  4. drthilina revised this gist Jul 5, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -105,7 +105,8 @@ $ mysql -u erpnext -p
    # After testing connection, exit mysql prompt >>> EXIT;

    # Initialize a frappe-bench working Directory
    $ bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13
    # bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13
    $ bench init frappe-bench --frappe-branch version-13

    # If you run in to a problem "No Directory 'install', or "yarn install", or conflicts, do the following and repeat above step
    $ sudo apt remove cmdtest
  5. drthilina revised this gist Jul 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -69,7 +69,7 @@ $ npm install -g yarn
    # Install WKHTMLTOPDF 0.12.6 (0.12.5 version will not render Letterhead headers and footers)
    $ apt install -y xvfb libfontconfig
    $ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
    $ sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
    $ sudo apt -y install ./wkhtmltox_0.12.6-1.focal_amd64.deb

    # Check WKHTMLTOPDF versions
    $ wkhtmltopdf --version
  6. drthilina revised this gist Jul 5, 2023. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -8,8 +8,7 @@ $ apt install -y git
    $ apt update -y && apt upgrade -y

    # Install Python 3.8 and dependencies
    $ sudo apt install -y python3-dev python3-setuptools python3-pip
    $ sudo apt install -y python3.8-venv software-properties-common curl
    $ sudo apt install -y python3-dev python3-setuptools python3-pip python3.8-venv software-properties-common curl

    # Install MariaDB
    $ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
  7. drthilina revised this gist Jul 5, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -9,13 +9,13 @@ $ apt update -y && apt upgrade -y

    # Install Python 3.8 and dependencies
    $ sudo apt install -y python3-dev python3-setuptools python3-pip
    $ sudo apt install python3.8-venv software-properties-common curl -y
    $ sudo apt install -y python3.8-venv software-properties-common curl

    # Install MariaDB
    $ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
    $ sudo bash mariadb_repo_setup --mariadb-server-version=10.6

    $ sudo apt install mariadb-server mariadb-client
    $ sudo apt install -y mariadb-server mariadb-client


    # Secure MariaDB Installation
  8. drthilina revised this gist Jul 5, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -61,7 +61,7 @@ $ sudo apt -y install nodejs
    $ node --version
    v14.x

    # Install NPM
    # NPM is auto installed, do update and upgrade.
    $ apt update -y && apt upgrade -y

    # Install YARN
  9. drthilina revised this gist Jul 4, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -217,6 +217,7 @@ $ nano site_config.json
    # another method
    # bench --site testing_site set-config hostname “https://<your_domain_name>”
    $ bench setup nginx
    $ sudo systemctl restart nginx

    # For good measure
    $ sudo reboot now
  10. drthilina revised this gist Jul 4, 2023. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -209,12 +209,13 @@ $ cd ~/frappe-bench/sites/testing_site

    # Adding the host name to the site_config.json (manually)
    $ nano site_config.json
    # add "host_name": "https://<your_domain_name>", below "db_type"
    "host_name": "https://<your_domain_name>"
    # add "hostname": "https://<your_domain_name>", below "db_type"
    "hostname": "https://<your_domain_name>"
    # Save and exit
    # cd to frappe-bench
    # below will add "hostname" to the site_config.json
    $ bench --site testing_site set-config hostname “https://<your_domain_name>
    # another method
    # bench --site testing_site set-config hostname “https://<your_domain_name>”
    $ bench setup nginx

    # For good measure
  11. drthilina revised this gist Jul 4, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -200,7 +200,7 @@ $ cd frappe-bench
    $ bench config dns_multitenant on

    # Finally get certification (You must have a domain name, else will not work)
    $ sudo bench setup lets-encrypt <your_domain_name>
    $ sudo bench setup lets-encrypt testing_site

    # The following commands will help WKHTMLTOPDF to correctly render PDF outputs
    #
  12. drthilina revised this gist Jul 4, 2023. 1 changed file with 29 additions and 18 deletions.
    47 changes: 29 additions & 18 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -7,15 +7,20 @@ $ apt install -y git
    # Ubuntu update and upgrade packages
    $ apt update -y && apt upgrade -y

    # Install Python 3 and dependencies
    $ apt install -y python3-dev python3-setuptools python3-pip virtualenv
    # Install Python 3.8 and dependencies
    $ sudo apt install -y python3-dev python3-setuptools python3-pip
    $ sudo apt install python3.8-venv software-properties-common curl -y

    # Install MariaDB
    $ apt install -y mariadb-server mariadb-client
    $ curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
    $ sudo bash mariadb_repo_setup --mariadb-server-version=10.6

    $ sudo apt install mariadb-server mariadb-client


    # Secure MariaDB Installation
    $ mysql_secure_installation
    Setup <your_password> and proceed forward with "y + Enter"
    Setup <your_root_password> and proceed forward with "y + Enter"

    # Add Configuration parameters to MariaDB relevant for Frappe framework
    $ nano /etc/mysql/my.cnf
    @@ -48,13 +53,16 @@ $ service mysql restart
    # Install Redis Server
    $ apt install -y redis-server

    # Install curl and install Node.js
    $ apt install curl -y
    $ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    $ apt install nodejs -y
    # Install Node.js 14.x
    $ sudo apt -y install dirmngr apt-transport-https lsb-release ca-certificates
    $ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    $ sudo apt -y install nodejs

    $ node --version
    v14.x

    # Install NPM
    $ apt update -y && apt install -y npm
    $ apt update -y && apt upgrade -y

    # Install YARN
    $ npm install -g yarn
    @@ -94,13 +102,16 @@ $ sudo apt install cron -y

    # Test Database connection
    $ mysql -u erpnext -p
    default password is 'erpnext'
    # After testing connection, exit mysql prompt >>> EXIT;

    # Initialize a frappe-bench working Directory
    $ bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13

    # If you run in to a problem "No Directory 'install', or "yarn install", do the following and repeat above step
    # If you run in to a problem "No Directory 'install', or "yarn install", or conflicts, do the following and repeat above step
    $ sudo apt remove cmdtest
    $ sudo apt remove yarn
    $ sudo yarn install --ignore-engines
    $ sudo npm install -g yarn

    # Navigate in to frappe-bench directory, except for "bench init" all other commands must happen from this directory
    @@ -112,10 +123,10 @@ $ bench start
    # press ctrl + C to stop and go back to prompt

    # Create a new site
    $ bench new-site v13.cubicoan.lk --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext'
    $ bench new-site testing_site --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext'

    # Let bench know the site can be used
    $ bench use v13.cubicoan.lk
    $ bench use testing_site

    # Test bench instance again
    $ bench start
    @@ -126,7 +137,7 @@ $ bench start
    $ bench get-app erpnext https://github.com/frappe/erpnext --branch version-13

    # Install ERPNext v13 in to the site
    $ bench --site v13.cubicoan.lk install-app erpnext
    $ bench --site testing_site install-app erpnext

    # Test bench instance again
    $ bench start
    @@ -189,21 +200,21 @@ $ cd frappe-bench
    $ bench config dns_multitenant on

    # Finally get certification (You must have a domain name, else will not work)
    $ sudo bench setup lets-encrypt v13.cubicoan.lk
    $ sudo bench setup lets-encrypt <your_domain_name>

    # The following commands will help WKHTMLTOPDF to correctly render PDF outputs
    #
    # Navigate to ~/frappe-bench/sites/<your_site>
    $ cd ~/frappe-bench/sites/v13.cubicoan.lk
    $ cd ~/frappe-bench/sites/testing_site

    # Adding the host name to the site_config.json (manually)
    $ nano site_config.json
    # add "host_name": "https://<your_site>", below "db_type"
    "host_name": "https://v13.cubicoan.lk"
    # add "host_name": "https://<your_domain_name>", below "db_type"
    "host_name": "https://<your_domain_name>"
    # Save and exit
    # cd to frappe-bench
    # below will add "hostname" to the site_config.json
    $ bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk
    $ bench --site testing_site set-config hostname “https://<your_domain_name>
    $ bench setup nginx

    # For good measure
  13. drthilina revised this gist Jul 28, 2022. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ $ bench --version
    $ sudo chown frappe -R /home/frappe

    # Install cron for managing scheduling
    sudo apt install cron -y
    $ sudo apt install cron -y

    # Test Database connection
    $ mysql -u erpnext -p
    @@ -192,8 +192,20 @@ $ bench config dns_multitenant on
    $ sudo bench setup lets-encrypt v13.cubicoan.lk

    # The following commands will help WKHTMLTOPDF to correctly render PDF outputs
    #
    # Navigate to ~/frappe-bench/sites/<your_site>
    $ cd ~/frappe-bench/sites/v13.cubicoan.lk

    # Adding the host name to the site_config.json (manually)
    $ nano site_config.json
    # add "host_name": "https://<your_site>", below "db_type"
    "host_name": "https://v13.cubicoan.lk"
    # Save and exit
    # cd to frappe-bench
    # below will add "hostname" to the site_config.json
    $ bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk”
    $ bench setup nginx

    # For good measure
    $ sudo reboot now

  14. drthilina revised this gist Jul 25, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -199,4 +199,4 @@ $ sudo reboot now



    whats remaining is securing the SSH connection and etting up UFW.
    whats remaining is securing the SSH connection and setting up UFW.
  15. drthilina revised this gist Jul 25, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -182,6 +182,9 @@ $ sudo snap install --classic certbot
    # Create symbolic link for Certbot (explained in lets-encrypt instructions)
    $ sudo ln -s /snap/bin/certbot /usr/bin/certbot

    # Navigate to frappe-bench folder
    $ cd frappe-bench

    # Turn on Multitenant in frappe-bench
    $ bench config dns_multitenant on

  16. drthilina revised this gist Jul 25, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -176,6 +176,9 @@ $ login as frappe
    # Install SNAP core etc.
    $ sudo snap install core; sudo snap refresh core

    # Install certbot
    $ sudo snap install --classic certbot

    # Create symbolic link for Certbot (explained in lets-encrypt instructions)
    $ sudo ln -s /snap/bin/certbot /usr/bin/certbot

  17. drthilina revised this gist Jul 25, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -158,7 +158,7 @@ $ sudo bench setup production frappe --yes
    # several outputs for frappe-bench... should appear

    # Check if other produciton environment tools are running
    $systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
    $ systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
    Output
    fail2ban.service enabled
    nginx.service enabled
  18. drthilina revised this gist Jul 25, 2022. 1 changed file with 26 additions and 29 deletions.
    55 changes: 26 additions & 29 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -157,43 +157,40 @@ $ sudo bench setup production frappe --yes
    # nginx -t
    # several outputs for frappe-bench... should appear

    # Check if other produciton environment tools are running
    $systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
    Output
    fail2ban.service enabled
    nginx.service enabled
    supervisor.service enabled

    systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
    Output
    fail2ban.service enabled
    nginx.service enabled
    supervisor.service enabled
    # Install SNAP for Centbot installation, this is for SSL
    $ sudo apt install snapd -y

    # For good measures lets reboot
    $ sudo reboot now

    sudo apt install snapd -y
    # Log in as non-root user
    $ login as frappe

    # Install SNAP core etc.
    $ sudo snap install core; sudo snap refresh core

    sudo reboot now
    # Create symbolic link for Certbot (explained in lets-encrypt instructions)
    $ sudo ln -s /snap/bin/certbot /usr/bin/certbot

    # Turn on Multitenant in frappe-bench
    $ bench config dns_multitenant on

    login as frappe
    # Finally get certification (You must have a domain name, else will not work)
    $ sudo bench setup lets-encrypt v13.cubicoan.lk

    # The following commands will help WKHTMLTOPDF to correctly render PDF outputs
    $ bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk”
    $ bench setup nginx
    # For good measure
    $ sudo reboot now

    sudo snap install core; sudo snap refresh core


    sudo ln -s /snap/bin/certbot /usr/bin/certbot


    bench config dns_multitenant on


    sudo bench setup lets-encrypt v13.cubicoan.lk


    bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk”
    bench setup nginx
    sudo systemctl restart nginx
    sudo systemctl restart supervisor
    or sudo reboot now





    whats remaining is UFW
    whats remaining is securing the SSH connection and etting up UFW.
  19. drthilina revised this gist Jul 25, 2022. 1 changed file with 24 additions and 5 deletions.
    29 changes: 24 additions & 5 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -125,18 +125,37 @@ $ bench start
    # Get bench app from GITHUB
    $ bench get-app erpnext https://github.com/frappe/erpnext --branch version-13

    # Install ERPNext v13 in to the site
    $ bench --site v13.cubicoan.lk install-app erpnext

    # Test bench instance again
    $ bench start
    # Goto <ip4>:8000 and it should show a wizard, you may proceed forward to complete the wizard
    # Once it is complete, press ctrl + C to stop and go back to prompt

    sudo bench setup production frappe --yes (redis server configuration fails)

    # ====================== Setting up for production ===========================

    cd frappe-bench/config

    # Automated setup for ERPNext for production
    $ sudo bench setup production frappe --yes
    # If you are lucky everyting will go smooth, for me redis server configuration fails

    redis-server redis_cache.conf (this will add the configuration to redis)
    # We need to manually add the redis configuration.
    # make sure you are in frappe home (~) directory
    $ cd frappe-bench/config

    # Run the script using redis-server command
    $ redis-server redis_cache.conf
    # Everything shoud be okay, press "ctrl + c" to cancel and go back to prompt

    sudo bench setup production frappe --yes
    (check supervisorctl reread, supervisorctl update, nginx -t, frappe-bench should appear)
    # Try production setup again, this time it should go through
    $ sudo bench setup production frappe --yes
    # check output for
    # supervisorctl reread
    # supervisorctl update
    # nginx -t
    # several outputs for frappe-bench... should appear


    systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
  20. drthilina revised this gist Jul 25, 2022. 1 changed file with 52 additions and 51 deletions.
    103 changes: 52 additions & 51 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,17 @@ default-character-set = utf8mb4
    # Restart MariaDB service
    $ systemctl restart mariadb

    # Login to MYSQL to create User and Database for FRAPPE framework to access
    $ mysql -u root -p
    >>> CREATE USER 'erpnext'@'localhost' IDENTIFIED BY 'erpnext';
    >>> GRANT ALL PRIVILEGES ON *.* TO 'erpnext'@'localhost' WITH GRANT OPTION;
    >>> CREATE DATABASE erpnext;
    >>> USE erpnext;
    >>> FLUSH PRIVILEGES;
    >>> EXIT;

    $ service mysql restart

    # Install Redis Server
    $ apt install -y redis-server

    @@ -48,7 +59,7 @@ $ apt update -y && apt install -y npm
    # Install YARN
    $ npm install -g yarn

    # Install WKHTMLTOPDF 0.12.6
    # Install WKHTMLTOPDF 0.12.6 (0.12.5 version will not render Letterhead headers and footers)
    $ apt install -y xvfb libfontconfig
    $ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
    $ sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
    @@ -57,72 +68,62 @@ $ sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb
    $ wkhtmltopdf --version
    wkhtmltopdf 0.12.6 (with patched qt)

    # Add non-root user for the FRAPPE framework
    $ adduser frappe
    <frappe_password>
    $ usermod -aG sudo frappe
    $ apt update -y && apt upgrade -y

    # Log in as the non-root user
    $ su frappe

    adduser frappe
    <frappe_password>


    usermod -aG sudo frappe


    apt update -y && apt upgrade -y


    su frappe


    cd


    sudo -H pip3 install frappe-bench


    check bench version
    bench --version
    # navigate in to the "frappe" user home directory
    $ cd

    # Install frappe-bench via pip
    $ sudo -H pip3 install frappe-bench

    sudo chown frappe -R /home/frappe
    # check bench version
    $ bench --version

    # Take ownership of home directory
    $ sudo chown frappe -R /home/frappe

    # Install cron for managing scheduling
    sudo apt install cron -y

    # Test Database connection
    $ mysql -u erpnext -p

    bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13


    sudo apt remove cmdtest
    sudo apt remove yarn
    sudo npm install -g yarn


    cd frappe-bench


    bench start (goto <ip4>:8000 and will show a not found error, but that means its running)

    su root
    mysql -u root -p
    CREATE USER 'erpnext'@'localhost' IDENTIFIED BY 'erpnext';
    GRANT ALL PRIVILEGES ON *.* TO 'erpnext'@'localhost' WITH GRANT OPTION;
    CREATE DATABASE erpnext;
    USE erpnext;
    FLUSH PRIVILEGES;
    EXIT;
    service mysql restart
    su frappe
    test mysql -u erpnext -p
    # Initialize a frappe-bench working Directory
    $ bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13

    bench new-site v13.cubicoan.lk --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext'
    # If you run in to a problem "No Directory 'install', or "yarn install", do the following and repeat above step
    $ sudo apt remove cmdtest
    $ sudo apt remove yarn
    $ sudo npm install -g yarn

    # Navigate in to frappe-bench directory, except for "bench init" all other commands must happen from this directory
    $ cd frappe-bench

    bench use v13.cubicoan.lk
    # Check bench instance
    $ bench start
    # Goto <ip4>:8000 and will show a not found error, but this means frappe-bench initialization was successful
    # press ctrl + C to stop and go back to prompt

    # Create a new site
    $ bench new-site v13.cubicoan.lk --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext'

    bench start (test if the Frappe framework is running)
    # Let bench know the site can be used
    $ bench use v13.cubicoan.lk

    # Test bench instance again
    $ bench start
    # Goto <ip4>:8000 and it should show a wizard, do not proceed forward
    # press ctrl + C to stop and go back to prompt

    bench get-app erpnext https://github.com/frappe/erpnext --branch version-13
    # Get bench app from GITHUB
    $ bench get-app erpnext https://github.com/frappe/erpnext --branch version-13


    sudo bench setup production frappe --yes (redis server configuration fails)
  21. drthilina revised this gist Jul 25, 2022. 1 changed file with 35 additions and 47 deletions.
    82 changes: 35 additions & 47 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -1,30 +1,26 @@
    root - 0OKkNl74YuCUcxf214
    Install ERPNext V13, FRAPPE-BENCH 13 on Ubuntu 20.04 and configure for production Environment


    apt install -y git
    # Install GIT
    $ apt install -y git

    # Ubuntu update and upgrade packages
    $ apt update -y && apt upgrade -y

    apt update && apt upgrade -y
    # Install Python 3 and dependencies
    $ apt install -y python3-dev python3-setuptools python3-pip virtualenv

    # Install MariaDB
    $ apt install -y mariadb-server mariadb-client

    apt install -y python3-dev python3-setuptools python3-pip virtualenv
    # Secure MariaDB Installation
    $ mysql_secure_installation
    Setup <your_password> and proceed forward with "y + Enter"

    # Add Configuration parameters to MariaDB relevant for Frappe framework
    $ nano /etc/mysql/my.cnf

    apt install -y mariadb-server mariadb-client


    mysql_secure_installation
    will ask for current password (enter for none): --> press enter here
    will ask to set root password: y and enter
    new password: <your_password>
    re-enter new password: <your_password>
    Remove anonymous users: y and enter
    Disallows root login remotely: y and enter
    Remove test database and access to it: y and enter
    Reload privilages table now: y and enter


    nano /etc/mysql/my.cnf (This will open mariadb main config file, add the following to end)
    # This will open mariadb main config file, add the following to end
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    @@ -33,30 +29,34 @@ collation-server = utf8mb4_unicode_ci
    [mysql]
    default-character-set = utf8mb4

    Save and exit (Ctrl + X then y and enter)


    service mysql restart


    apt install -y redis-server


    apt install curl -y
    # Save and exit

    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    # Restart MariaDB service
    $ systemctl restart mariadb

    # Install Redis Server
    $ apt install -y redis-server

    apt install nodejs -y
    # Install curl and install Node.js
    $ apt install curl -y
    $ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    $ apt install nodejs -y

    # Install NPM
    $ apt update -y && apt install -y npm

    apt update -y && apt install -y npm
    # Install YARN
    $ npm install -g yarn

    # Install WKHTMLTOPDF 0.12.6
    $ apt install -y xvfb libfontconfig
    $ wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
    $ sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb

    npm install -g yarn

    # Check WKHTMLTOPDF versions
    $ wkhtmltopdf --version
    wkhtmltopdf 0.12.6 (with patched qt)

    apt install -y xvfb libfontconfig wkhtmltopdf <- this will install 0.12.5


    adduser frappe
    @@ -166,17 +166,6 @@ bench config dns_multitenant on
    sudo bench setup lets-encrypt v13.cubicoan.lk


    New - >
    wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
    sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb

    $ wkhtmltopdf --version
    wkhtmltopdf 0.12.6 (with patched qt)

    $ wkhtmltoimage --version
    wkhtmltoimage 0.12.6 (with patched qt)


    bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk”
    bench setup nginx
    sudo systemctl restart nginx
    @@ -187,5 +176,4 @@ or sudo reboot now




    whats remaining is UFW
  22. drthilina created this gist Jul 25, 2022.
    191 changes: 191 additions & 0 deletions 1_erpnext13_production.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,191 @@
    root - 0OKkNl74YuCUcxf214


    apt install -y git


    apt update && apt upgrade -y


    apt install -y python3-dev python3-setuptools python3-pip virtualenv


    apt install -y mariadb-server mariadb-client


    mysql_secure_installation
    will ask for current password (enter for none): --> press enter here
    will ask to set root password: y and enter
    new password: <your_password>
    re-enter new password: <your_password>
    Remove anonymous users: y and enter
    Disallows root login remotely: y and enter
    Remove test database and access to it: y and enter
    Reload privilages table now: y and enter


    nano /etc/mysql/my.cnf (This will open mariadb main config file, add the following to end)
    [mysqld]
    character-set-client-handshake = FALSE
    character-set-server = utf8mb4
    collation-server = utf8mb4_unicode_ci

    [mysql]
    default-character-set = utf8mb4

    Save and exit (Ctrl + X then y and enter)


    service mysql restart


    apt install -y redis-server


    apt install curl -y

    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash


    apt install nodejs -y


    apt update -y && apt install -y npm


    npm install -g yarn


    apt install -y xvfb libfontconfig wkhtmltopdf <- this will install 0.12.5


    adduser frappe
    <frappe_password>


    usermod -aG sudo frappe


    apt update -y && apt upgrade -y


    su frappe


    cd


    sudo -H pip3 install frappe-bench


    check bench version
    bench --version


    sudo chown frappe -R /home/frappe


    sudo apt install cron -y


    bench init /home/frappe/frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-13


    sudo apt remove cmdtest
    sudo apt remove yarn
    sudo npm install -g yarn


    cd frappe-bench


    bench start (goto <ip4>:8000 and will show a not found error, but that means its running)

    su root
    mysql -u root -p
    CREATE USER 'erpnext'@'localhost' IDENTIFIED BY 'erpnext';
    GRANT ALL PRIVILEGES ON *.* TO 'erpnext'@'localhost' WITH GRANT OPTION;
    CREATE DATABASE erpnext;
    USE erpnext;
    FLUSH PRIVILEGES;
    EXIT;
    service mysql restart
    su frappe
    test mysql -u erpnext -p

    bench new-site v13.cubicoan.lk --admin-password '<admin_password>' --mariadb-root-username erpnext --mariadb-root-password 'erpnext'


    bench use v13.cubicoan.lk


    bench start (test if the Frappe framework is running)


    bench get-app erpnext https://github.com/frappe/erpnext --branch version-13


    sudo bench setup production frappe --yes (redis server configuration fails)


    cd frappe-bench/config


    redis-server redis_cache.conf (this will add the configuration to redis)


    sudo bench setup production frappe --yes
    (check supervisorctl reread, supervisorctl update, nginx -t, frappe-bench should appear)


    systemctl list-unit-files | grep 'fail2ban\|nginx\|supervisor'
    Output
    fail2ban.service enabled
    nginx.service enabled
    supervisor.service enabled


    sudo apt install snapd -y


    sudo reboot now


    login as frappe


    sudo snap install core; sudo snap refresh core


    sudo ln -s /snap/bin/certbot /usr/bin/certbot


    bench config dns_multitenant on


    sudo bench setup lets-encrypt v13.cubicoan.lk


    New - >
    wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb
    sudo apt install ./wkhtmltox_0.12.6-1.focal_amd64.deb

    $ wkhtmltopdf --version
    wkhtmltopdf 0.12.6 (with patched qt)

    $ wkhtmltoimage --version
    wkhtmltoimage 0.12.6 (with patched qt)


    bench --site v13.cubicoan.lk set-config hostname “https://v13.cubicoan.lk”
    bench setup nginx
    sudo systemctl restart nginx
    sudo systemctl restart supervisor
    or sudo reboot now






    whats remaining is UFW