check ubuntu version just for curiosity
$ lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial

become root user
$ sudo -s


update repo
$ apt-get update
$ apt-get upgrade

install web server
$ apt-get install nginx

you should see your nginx default page (check aws settings for public ip)

nginx commands you might need later
$ service nginx status
$ service nginx stop
$ service nginx restart

your root directory is : /usr/share/nginx/html/

check nginx syntax
$ nginx -t

INSTALL MARIADB–ubuntu_xenial&version=10.1

setup MariaDB repo for version 10.1

$ sudo apt-get install software-properties-common
$ sudo apt-key adv –recv-keys –keyserver hkp:// 0xF1656F24C74CD1D8
$ sudo add-apt-repository ‘deb [arch=amd64,i386,ppc64el] xenial main’

we are ready to install mariadb 10.1
$ sudo apt update
$ sudo apt install mariadb-server mariadb-client

it will ask for password enter twice on purple screen
never forget this database password

now finish the mariadb installation
$ /usr/bin/mysql_secure_installation

enter current password for root: (the one you entered)
change root password? (type N)
Remove anonymous users? (type Y)
Disallow root login remotely? (type N)
Remove test database and access to it? (type y)
Reload privilage tables now? (type y)

let’s verify mariadb is installed
$ mysql -u root -p

Enter password: (type the root password you given)

now list the databases
$ MariaDB [(none)]> show databases;

| Database |
| information_schema |
| mysql |
| performance_schema |
3 rows in set (0.00 sec)

$ MariaDB [(none)]> exit;

you can also look at mariadb status
$ sudo service mysql status
Ctrl + C to exit

MariaDB commands
$ sudo service mysql status
$ sudo service mysql start
$ sudo service mysql stop
$ sudo service mysql restart


$ systemctl start mysql
$ systemctl enable mysql
$ systemctl restart mysql
$ systemctl status mysql


install all required php 7 files

$ apt-get install php7.0 php7.0-fpm php7.0-mysql php7.0-curl php7.0-gd php7.0-mbstring php7.0-xml php7.0-json php7.0-cli

check version
$ php --version

PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies

php-fm commands
$ systemctl start php7.0-fpm
$ systemctl stop php7.0-fpm
$ systemctl status php7.0-fpm
$ systemctl restart php7.0-fpm

edit php-fpm config file
$ sudo vi /etc/php/7.0/fpm/php.ini

change time zone and fix_pathinfo

; Defines the default timezone used by the date functions
date.timezone = America/New_York

restart php-fpm

$ systemctl restart php7.0-fpm

add index.php to the index on nginx default ini file
$ vi /etc/nginx/sites-available/default

index index.php index.html index.htm index.nginx-debian.html;
server_name ip;


You can create multiple web sites under the root directory /usr/share/nginx/html/
Just create your website directory under root, let’s say it’s called getyanji

first create the working directory
$ mkdir /usr/share/nginx/html/getyanji

We won’t use default anymore.. etc/nginx/sites-enabled/default

create server files from default
$ cp /etc/nginx/sites-available/default /etc/nginx/sites-available/getyanji

create links to the enabled sites
$ sudo ln -s /etc/nginx/sites-available/getyanji /etc/nginx/sites-enabled/

you later use the sites’ own config files
$ sudo vi /etc/nginx/sites-available/getyanji

Repeat the above step for another new website!


Note: Your document root is usr/share/nginx/html/

let’s create an info php file to show the php settings
$ vi /usr/share/nginx/html/getyanji/info.php

type this save and close the file:

check out php info page


$ apt-get update
$ apt-get install phpmyadmin

In purple screen it asks apache or lighttpd, we will select neither of it, press Tab key on your keyboard to skip to the OK button, then press enter
Configure database for phpymadmin with dbconfig-common? (press Yes)
enter same passwords you entered before (3 times) The first password is actually the phpmyadmin web login password but we make it the same to avoid confusion

now let the nginx server finds the location of phpmyadmin
$ ln -s /usr/share/phpmyadmin /usr/share/nginx/html/getyanji

$ phpenmod mcrypt
$ phpenmod mbstring

then security limit extensions
$ vi /etc/php/7.0/fpm/pool.d/www.conf

security.limit_extensions = .php .php3 .php4 .php5

restart web server
$ service nginx restart
restart php-fpm
$ systemctl restart php7.0-fpm

now you should see your phpmadmin page, login with root username and password you have given before

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s