LAMP with Yii1

Installing PHP

    sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

    Install php extensions

        sudo apt-get install php5-mysql
        sudo apt-get install php5-sqlite
        sudo apt-get install php5.6-mbstring
        sudo apt-get install libapache2-mod-php5.6

In most cases, we’ll want to modify the way that Apache serves files when a directory is requested. 
Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. 
We want to tell our web server to prefer PHP files, so we’ll make Apache look for an index.php file first.

To do this, type this command to open the dir.conf file in a text editor with root privileges:

sudo nano /etc/apache2/mods-enabled/dir.conf
It will look like this:

    DirectoryIndex index.html index.cgi index.php index.xhtml index.htm

We want to move the PHP index file highlighted above to the first position after the DirectoryIndex specification, like this:

    DirectoryIndex index.php index.html index.cgi index.xhtml index.htm


Install Multiple PHP Versions on Ubuntu 16.04

Install PHP 5.6

Step 1: Update Apt-Get
apt-get update && apt-get upgrade
apt-get install -y software-properties-common
add-apt-repository ppa:ondrej/php
apt-get update

Step 2: Install PHP 5.6
apt-get install -y php5.6

Changing PHP Version for Apache (if your server have more than one php version)

a2dismod php7.0; a2enmod php5.6; service apache2 restart
a2dismod php5.6; a2enmod php7.0; service apache2 restart

Changing PHP Version for Ubuntu

update-alternatives --config php
and then choose one php version for command line ( Ubuntu )


Installing Apache Web Server

Step 1 — 
    sudo apt update
    sudo apt install apache2

Step 2 — Adjusting the Firewall

    sudo ufw app list
    sudo ufw allow 'Apache'
    sudo ufw status

    or custom port allow

    sudo ufw allow 8080
    sudo ufw reload

Step 3 — Checking your Web Server

    sudo systemctl status apache2

    hostname -I
    at command line : curl -4
    at browser : http://your_server_ip

Step 4 — Managing the Apache Process

    sudo systemctl stop apache2
    sudo systemctl start apache2
    sudo systemctl restart apache2
    sudo systemctl reload apache2
    sudo systemctl disable apache2
    sudo systemctl enable apache2

Step 5 — Setting Up Virtual Hosts (Recommended)

    sudo mkdir /var/www/your_domain
    sudo chown -R $USER:$USER /var/www/your_domain
    sudo chmod -R 755 /var/www/your_domain

    nano /var/www/your_domain/index.html
    and added some html code into index.html

    sudo nano /etc/apache2/sites-available/your_domain.conf

        ServerAdmin webmaster@localhost
        ServerName your_domain
        ServerAlias www.your_domain
        DocumentRoot /var/www/your_domain
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        ServerName ipaddress
        DocumentRoot /var/www/html/testwebsite
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

Allowing Rewrite rules to Apache2 Web Server at Ubuntu

    a2enmod rewrite
    systemctl restart apache2

Let’s enable the file with the a2ensite tool:

    sudo a2ensite your_domain.conf

Disable the default site defined in 000-default.conf:

    sudo a2dissite 000-default.conf

Next, let’s test for configuration errors:

    sudo apache2ctl configtest

You should see the following output:

Syntax OK

Restart Apache to implement your changes:

    sudo systemctl restart apache2

Checking Errors log at Apache Server



Installing MySQL to Manage Site Data

    sudo apt install mysql-server php5-mysql
    sudo mysql_secure_installation

Allow MySql without 'sudo' at command line
    sudo mysql
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
    mysql> SELECT user,authentication_string,plugin,host FROM mysql.user;
    mysql> exit
and then, you can access mysql without sudo 'mysql -u root -p'

Adding new user and grant databases / only one database

    // Creating new database user
    CREATE USER 'YourUserName'@'localhost' IDENTIFIED BY 'YourPassword';
    CREATE USER 'YourUserName'@'%' IDENTIFIED BY 'YourPassword';

    // Granting the one user to all database
    GRANT ALL ON *.* TO 'YourUserName'@'localhost';
    GRANT ALL ON *.* TO 'YourUserName'@'%';

    // Granting the one user to one database
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'localhost';
    GRANT ALL ON YourDatabaseName.* TO 'YourUserName'@'%';



Ubuntu OS မွာ Apache ၿဖင္႔ PHP ကို Multiple Versions ေၿပာင္းလဲ အသံုးၿပဳၿခင္း

Ubuntu OS မွာ Apache ၿဖင္႔ PHP ကို Multiple Versions ေၿပာင္းလဲ အသံုးၿပဳၿခင္း
အကယ္၍ မိမိ development လုပ္ေနေသာ Environment မွာ PHP ကို Version တစ္မ်ဴိးထက္ပိုၿပီး Install လုပ္ထားရတယ္ ( eg. 5.6 and 7.3 )။ မိမိရဲ႕ Project ရဲ႕လုိအပ္ခ်က္အရ PHP ကို Version 5.6 နဲ႕ 7.3 Version ၂ မ်ဴိးလံုးအသံုးၿပဳဖုိ႕လိုအပ္ခဲ႕လွ်င္
ဥပမာ အေနနဲ႕
Project1 – Yii Framework Version 1 – PHP 5.6
Project2 – Laravel Framework Version 5.7 – PHP 7.3
How to change PHP Version for Apache
Enable php 5.6  and disable php 7.3
sudo a2dismod php7.3
sudo a2enmod php5.6
sudo service apache2 restart
Enable php 7.3  and Disable php 5.6
sudo a2dismod php5.6
sudo a2enmod php7.3
sudo service apache2 restart
/var/www/html folder ထဲတြင္ info.php ဆိုၿပီး PHP Script File တစ္ခုတည္ေဆာက္ၿပီး
ဆုိၿပီး သိမ္းဆည္းလိုက္ပါ။ ၿပီးလွ်င္ Browser မွ http://localhost/info.php ဆိုၿပီးေခၚၿကည္႔လုိက္ပါ။
မိမိရဲ႕ Apache Web Server ရဲ႕ လက္ရွိ PHP Version ကို ၿမင္ရပါလိမ္႔မယ္။
How to change PHP Version for Ubuntu ( command line usage )
Terminal ( Command Line ) တြင္
sudo update-alternatives –config php
PHP Version selection Questions ေပၚလာပါလိမ္႔မယ္။ မိမိ အလုိရွိေသာ PHP Version ကိုေရြးခ်ယ္ ေၿပာင္းလဲလုိ႕ရပါသည္။ ေၿပာင္းလဲၿပီးစီးသည္႔အခါ Teminal တြင္
php -v
ၿဖင္႔ PHP current version ကို ေခၚၿကည္ႏုိင္ပါသည္။
OS – Ubuntu – 16.04 / 18.04
Web Server – Apache
PHP – 5.6 & 7.3
Wai Yan Aung


HOw to install JHipster ( Latest Version )

Quick setup

  1. Install Java 11. We recommend you use AdoptOpenJDK builds, as they are open source and free.
  2. Install Node.js from the Node.js website (please use an LTS 64-bit version, non-LTS versions are not supported)
  3. Install JHipster: npm install -g generator-jhipster
  4. (optional) If you want to use a module or a blueprint (for instance from the JHipster Marketplace), install Yeomannpm install -g yo

Ref ::


How to install JHipster Old Version
npm install -g generator-jhipster@5.2.1


Uninstall JHipster 
whereis jhipster
sudo rm -rf /opt/node-v10.16.0-linux-x64/bin/jhipster


Nginx: 413 – Request Entity Too Large Error at Ubuntu and Solution

Nginx: 413 – Request Entity Too Large Error and Solution

Nginx configuration

To fix this issue edit your nginx.conf. Open the Terminal or login to the remote server using ssh client. Type the following command to edit your nginx.conf using a text editor such as vi or joe or nano:
# vi /etc/nginx/nginx.conf

Use nano text editor:
$ sudo nano /etc/nginx/nginx.conf

Must be run as root:
# vi /usr/local/nginx/conf/nginx.conf

Add the following line to http or server or location context to increase the size limit in nginx.conf, enter:

# set client body size to 2M #
client_max_body_size 2M;

The client_max_body_size directive assigns the maximum accepted body size of client request, indicated by the line Content-Length in the header of request. If size is greater the given one, then the client gets the error “Request Entity Too Large” (413).
Save and close the file. Reload the nginx webserver, enter:
# /usr/local/nginx/sbin/nginx -s reload

Use nginx itself to reload it:
# /sbin/nginx -s reload

For RHEL/CentOS/Debian/Ubuntu Linux, try:
# service nginx reload

If you are using systemd based system run:
$ sudo systemctl reload nginx.service

PHP configuration (optional)

Your php installation also put limits on upload file size. Edit php.ini and set the following directives

;This sets the maximum amount of memory in bytes that a script is allowed to allocate
memory_limit = 32M

;The maximum size of an uploaded file.
upload_max_filesize = 2M

;Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize
post_max_size = 3M
If you are using PHP-FPM, restart it as follows:
$ sudo systemctl restart php-fpm
## OR ##
$ sudo systemctl restart php7.0-fpm.service
## OR ##
$ sudo /usr/local/etc/rc.d/php-fpm restart

Save and close the file. Make sure you reload/restart back-end apache or nginx web server as per your setup.

Enable Remote Connections Mysql Ubuntu

To expose MySQL to anything other than localhost you will have to have the following line

For mysql version 5.6 and below

uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback

For mysql version 5.7 and above

uncommented in /etc/mysql/mysql.conf.d/mysqld.cnf and assigned to your computers IP address and not loopback

#Replace xxx with your IP Address
bind-address =
Or add a bind-address = if you don’t want to specify the IP

Then stop and restart MySQL with the new my.cnf entry. Once running go to the terminal and enter the following command.

lsof -i -P | grep :3306
That should come back something like this with your actual IP in the xxx’s

mysqld 1046 mysql 10u IPv4 5203 0t0 TCP (LISTEN)
If the above statement returns correctly you will then be able to accept remote users. However for a remote user to connect with the correct priveleges you need to have that user created in both the localhost and ‘%’ as in.

CREATE USER ‘myuser’@’localhost’ IDENTIFIED BY ‘mypass’;
CREATE USER ‘myuser’@’%’ IDENTIFIED BY ‘mypass’;

GRANT ALL ON *.* TO ‘myuser’@’localhost’;
GRANT ALL ON *.* TO ‘myuser’@’%’;
and finally,


Restart Mysql service and test again with new user to mysql from remote access.