Skip to content

Instantly share code, notes, and snippets.

@anilprasad
Forked from drthilina/1_erpnext13_public.sh
Created November 8, 2022 07:52
Show Gist options
  • Select an option

  • Save anilprasad/690c38e3bc0c8d3ba1a3085fb020bdb0 to your computer and use it in GitHub Desktop.

Select an option

Save anilprasad/690c38e3bc0c8d3ba1a3085fb020bdb0 to your computer and use it in GitHub Desktop.

Revisions

  1. @drthilina 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

  2. @drthilina 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.
  3. @drthilina 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

  4. @drthilina 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

  5. @drthilina 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
  6. @drthilina 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.
  7. @drthilina 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'
  8. @drthilina 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)
  9. @drthilina 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
  10. @drthilina 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