Nov 1, 2018

ERPNext on Gentoo Linux

Before deciding what "Operating System" we have to set on server(s), the decision is always arbitrary. For my personal flavor, I have a certain choice, LINUX Base operating system. Then there are another consideration, what Linux Distro is "best" for server(s). This decision is crucial, imagine ... we decided to put an operating system on server, after 3-5 years we change our mind to replace the OS, it will consumed huge time, energy and passion. Today is 2018, I have to set a server for "simple" need. Just one server to host an ERP application and cloud base storage system. Server is old, build in 2010 anchored by X5500 Intel server board, powered by ONE XEON 5260 Hexa Core CPU and 4x4 GB ECC Memory. 1x1 TB and 1x500GB HDD.I hooked Gentoo system to set on the unit, with the reason, I trust to gentoo and bit familiar with the system.
. Discussion.
I have scary feeling reading this article WHY GENTOO SHOULDN'T BE ON YOUR SERVER, I supposed, the article is written by a tech savy person and This interesting article, I don't understand why people use Gentoo in production servers. Is it good practice? I can see so many downsides. . Just read long discussions and you will see very interesting debate.
I am not Tech Savy Person, far from being an expert for linux, I do like play and bit adventure. I am NOT a server administrator as well. Now I need to support small company required an ERP system. The company has 3 (three) outlet and geographically separated into Three Residents. The server will play very important role and have to capable to operate 24 hours Non Stop.

At the time I published this post, the server have been running for 286 days without any serious problem.This month We decided to build a back up server, in case the main server face problems, we have something in hand to keep the business running. The server unit is used IBM X3200 Powered by single Hexa Core Intel(R) Xeon(R) CPU X3440 @ 2.53GHz with 4x2 GB ECC RAM

Server Maintenance
Switch off the server once a week, on Sunday 19.00 and Switched-On on Monday 06.00. Database and file back up once a week on Monday evening. That's all.

The Server Set Up
    Hook up Gentoo system. Follow the incredible Gentoo Handbook
    Basic gentoo system is set now

    Note :
    Do not forget to ensure you are on Python 2.7 version
    # eselect python list
    Available Python interpreters, in order of preference:
    [1] python2.7
    [2] python3.6
    # eselect python set 1

    Grab Required component for ERP Next, this is also arbitrary depending on your OS installation. Commonly people install "Basic System", thus the pre-requisite component are :
      # emerge -vp net-libs/nodejs (will also install npm)
      # emerge -vp dev-db/mariadb
      # emerge -vp dev-python/pip
      # emerge -vp media-gfx/wkhtmltopdf
      # emerge -vp www-server/nginx

      # emerge -vp app-admin/supervisor
      # npm install -g yarn

      Best Way to Install Redis-server on gentoo is by following Redis HomePage
    Tweak MariaDB
    # nano -w /etc/mysql/my.ncf
    Paste below to openen window
    [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

    Create root password for MariaDB
    $ mysqladmin -u root password YOUR_OWN_PASSWORD_HERE
    Add service to default level
    # rc-update add mysql default
    # rc-update add supervisord default
    # rc-update add nginx default

    Optional but suggested : Reboot server

Install ERPNext
$ cd
$ git clone https://github.com/frappe/bench bench
Many tutorial/instruction to clone into a folder named bench-repo. It is actually just a name for easier to distinguish. You can use any name you wants
Wait until the clone process finish (time consuming is depending on your internet speed) and no error
$ pip install --user -e bench-repo # no root required installing as user
Wait until the install process finish
$ echo "export PATH=$HOME/.local/bin:$PATH" >> ~/.bashrc # add ~/.local/bin to path if not already there.
$ source ~/.bashrc
$ bench init semayi-bench # we can use any name we want
$ cd semayi-bench
$ bench get-app erpnext https://github.com/frappe/erpnext
Finished install Frappe with Erpnext apps

Install/Create a Erpnext Site
    Easy way - remember your mysql root user password !!
    $ cd semayi-bench
    $ bench new-site site_name_com --install-app erpnext
    just wait for a while... you will be Asked to key in Mysql root password and CREATE NEW site Administrator password
    No error message appear .... you are done
    Hard Way
    Create a mysql database for a site
    $ mysql -u root -p
    $ Enter Password :
    $ MariaDB [(none)]> CREATE DATABASES database_name_here;
    $ MariaDB [(none)]> GRANT ALL PRIVILEGES ON database_name_you_created.* TO 'root'@'localhost' IDENTIFIED BY 'your_root_mysql_password' WITH GRANT OPTION; $ MariaDB [(none)]> \q;
    go to created bench at appropriate path
    $ cd ~/semayi-bench
    $ bench new-site sitename --db-name name_of_database_you_created --mariadb-root-username root --mariadb-root-password your_mysql_root_password --install-app erpnext --verbose --force
    Wait until the process finished. No Error you are done. Got Error go to forum

Test and check
    $ cd ~/semayi-bench
    $ bench start
    Open your browser and go to your server IP address at port 8000 i.e 192.168.102.111:8000 You have to see Erpnext site alive

Setting up Production
$ cd semayi-bench/
$ bench setup nginx, supervisor command working well on ubuntu
or probably debian base distro. But Not Working on Gentoo, due to different structure and method.
In ubuntu nginx and redis server configuration in frappe bench has symlink to nginx and supervisor configuration
For Gentoo have to set manually, but it is easier with many options
For someone has many website managed by nginx, it is good idea to create a folder conf.d and add include path at nginx.conf then create symlink from nginx configuration in erpnext bench system
This nginx configuration also applicable for redis managed by supervisord. Just add include:/path/of/redis.conf/ in the /etc/supervisor.conf

End of Game

Real Multilib Userland on Linux

Read multilib requirement on Android rom building and other stuff. About two years absent from getting rid with android rom. I have time to...