How To Install LAMP Stack on Ubuntu 16.04

Install LAMP Stack on Ubuntu 16

LAMP represents a full featured stack containing the most popular web server known as Apache, the most popular database server MySQL and the most popular open-source web programming language known as PHP. All components are free and open-source software, and the combination is suitable for building dynamic web pages.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation LAMP (Linux Apache, MySQL and PHP) on Ubuntu 16.04 server.

Install LAMP Stack on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

apt-get update
apt-get upgrade

Step 2. Installing Apache on Ubuntu 16.04.

We will be installing Apache with apt-get, which is the default package manager for ubuntu. Your also required to install libapache2-mod-php module to work PHP with Apache2:

apt-get install apache2 libapache2-mod-php

After installing apache services on your system, start all required services:

systemctl enable apache2
systemctl start apache2
systemctl status apache2

You can verify that Apache is really running by opening your favorite web browser and entering the URL http://your-server’s-address, if it is installed, then you will see this:
apache2-ubuntu-default-page
Step 3. Installing MySQL on Ubuntu 16.04

Now that we have our web server up and running, it is time to install MySQL. MySQL is a database management system. Basically, it will organize and provide access to databases where our site can store information:

apt-get install mysql-server php7.0-mysql

Once complete, you can verify MySQL is installed by running the below command:

systemctl status mysql
systemctl start mysql

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

To log into MySQL, use the following command (note that it’s the same command you would use to log into a MySQL database):

mysql -u root -p

Step 4. Installing PHP 7 on Ubuntu 16.04

PHP 7.0 is now the default PHP package shipping in Ubuntu LTS 16.04 (Xenial Xerus), Now install PHP 7 with the following command:

sudo apt-get install php7.0 php7.0-mysql php7.0-curl php7.0-gd php7.0-json php7.0-opcache php7.0-xml mcrypt php7.0-mcrypt

If you like to search all the available PHP 7 modules you can use to command:

sudo apt-cache search php7-*

Your server should restart Apache automatically after the installation of both MySQL and PHP. If it doesn’t, execute this command:

sudo systemctl restart apache2
sudo systemctl restart mysql

To test PHP, create a test file named info.php with he content below. Save the file, then browse to it to see if PHP is working:

nano /var/www/html/info.php
<!--?php phpinfo(); ?-->

Try to access it at http://your_server_ip/info.php . If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.
LAMP-ubuntu-16.04
Congratulation’s! You have successfully installed LAMP stack. Thanks for using this tutorial for installing LAMP (LinuxApache, MySQL andPHP) in Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official Apache, MySQL and PHP web site.

How To Install ATutor on Ubuntu 16.04

Install ATutor on Ubuntu 16

ATutor is an Open Source Web-based Learning Content Management System (LCMS) designed with accessibility and adaptability in mind. Administrators can install or update ATutor in minutes, and develop custom templates to give ATutor a new look. Educators can quickly assemble, package, and redistribute Web-based instructional content, easily retrieve and import prepackaged content, and conduct their courses online. Students learn in an adaptive learning environment.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Habari on a Ubuntu 16.04 server.

Install ATutor on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install LAMP (Linux, Apache, MariaDB, PHP) server.

A Ubuntu 16.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:

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

Step 3. Installing ATutor.

First thing to do is to go to ATutor’s download page and download the latest stable version of ATutor, At the moment of writing this article it is version 2.2.1:

wget http://downloads.sourceforge.net/project/atutor/ATutor%202/ATutor-2.2.1.tar.gz?r=http%3A%2F%2Fwww.atutor.ca%2Fatutor%2Fdownload.php -O ATutor-2.2.1.tar.gz

Unpack the ATutor archive to the document root directory on your server:

tar -zxvf ATutor-2.2.1.tar.gz
mv ATutor/ /var/www/html/atutor/

We will need to change some folders permissions:

chown -R www-data: /var/www/html/atutor/

Step 4. Configuring MariaDB for ATutor.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next we will need to log in to the MariaDB console and create a database for the ATutor. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for ATutor installation:

create database atutor;
grant all privileges on atutor.* to atutoruser@localhost identified by 'your_password';
flush privileges;
exit

Step 5. Configuring Apache web server for ATutor.

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘atutor.conf’ on your virtual server:

sudo a2enmod rewrite
touch /etc/apache2/sites-available/atutor.conf
ln -s /etc/apache2/sites-available/atutor.conf /etc/apache2/sites-enabled/atutor.conf
nano /etc/apache2/sites-available/atutor.conf

Add the following lines:

ServerAdmin [email protected]
DocumentRoot "/var/www/html/atutor/"
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog "/var/log/apache2/yourdomain.com-error_log"
CustomLog "/var/log/apache2/yourdomain.com-access_log" combined

Now, we can restart Apache web server so that the changes take place:

systemctl restart apache2.service

Step 6. Accessing ATutor.

ATutor will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com/ or http://server-ip and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulation’s! You have successfully installed ATutor. Thanks for using this tutorial for installing ATutor (Learning Management System) on your Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official ATutor web site.

How To Install WordPress on Ubuntu 16.04

Install WordPress on Ubuntu 16

WordPress is an online, open source website creation tool written in PHP. But in non-geek speak, it’s probably the easiest and most powerful blogging and website content management system (or CMS) in existence today.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation WordPress content management systems on a Ubuntu 16.04 server.

Install WordPress on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install LAMP (Linux, Apache, MariaDB, PHP) server.

A Ubuntu 16.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:

apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-xmlrpc php7.0-gd

Step 3. Installing WordPress.

First thing to do is to go to WordPress’s download page and download the latest stable version of WordPress, At the moment of writing this article it is version 4.5.1:

wget http://wordpress.org/latest.zip

Unpack the WordPress archive to the document root directory on your server:

unzip -q latest.zip -d /var/www/html/
cd wordpress
cp -a * ..

We will need to change some folders permissions:

chown www-data:www-data -R /var/www/html/

We need to create the upload directory manually:

mkdir -p /var/www/html/wp-content/uploads

Allow the Apache web server to write to the uploads directory. Do this by assigning group ownership of this directory to your web server which will allow Apache to create files and directories. Issue the following command:

chown www-data:www-data -R /var/www/html/wp-content/uploads

Step 4. Configuring MariaDB for WordPress.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next we will need to log in to the MariaDB console and create a database for the WordPress. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for WordPress installation:

CREATE DATABASE wordpress character set utf8 collate utf8_bin;
GRANT ALL PRIVILEGES on wordpress.* to 'wpuser'@'localhost' identified by 'your_password';
FLUSH PRIVILEGES;
exit

Step 5. Configuring WordPress

In this step we will configure the main configuration file of WordPress, where we need to configure it’s basic parameters so that it can be connected with the database and user:

mv wp-config-sample.php wp-config.php

Now open it using any of your favourite editor, to make any changes in the WordPress configuration file:

nano wp-config.php

Here are the values that we need to update according to our previous database and user’s setup:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wpuser');

/** MySQL database password */
define('DB_PASSWORD', 'your_password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

Step 6. Configuring Apache web server for WordPress.

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘wordpress.conf’ on your virtual server:

sudo a2enmod rewrite
touch /etc/apache2/sites-available/wordpress.conf
ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/wordpress.conf
nano /etc/apache2/sites-available/wordpress.conf

Add the following lines:

ServerAdmin [email protected]
DocumentRoot /var/www/html/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common

Now, we can restart Apache web server so that the changes take place:

systemctl restart apache2.service

Step 7. Accessing WordPress.

WordPress will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com or http://server-ip/ and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulation’s! You have successfully installed WordPress. Thanks for using this tutorial for installing WordPress CMS (Content Management Systems) on your Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official WordPress web site.

How To Install Prosper202 on Ubuntu 16.04

Install Prosper202 on Ubuntu 16

Prosper202 is a free tracking software which can be used to do advance tracking. The best part about this software is that it is a self-hosted software which helps us to track and run campaigns.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Prosper202 on a Ubuntu 16.04 server.

Install Prosper202 on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install LAMP (Linux, Apache, MariaDB, PHP) server.

A Ubuntu 16.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:

sudo apt-get install php5 libapache2-mod-php5 php5-xmlrpc php5-mysql php5-curl php5-gd

Step 3. Installing Prosper202.

First thing to do is to go to Prosper202’s download page and download the latest stable version of Prosper202, At the moment of writing this article it is version 1.9.30:

mkdir /var/www/prosper202
cd /var/www/prosper202/
wget http://my.tracking202.com/clickserver/download/latest &amp;&amp; unzip latest

We will need to change some folders permissions:

chown www-data:www-data -R /var/www/prosper202

Step 4. Configuring MariaDB for Prosper202.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next we will need to log in to the MariaDB console and create a database for the Prosper202. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Prosper202 installation:

CREATE DATABASE prosper202DB;
GRANT ALL PRIVILEGES ON prosper202DB.* TO 'prosper202'@'localhost' IDENTIFIED BY 'YoUrPaSsWoRd';
FLUSH PRIVILEGES;
\q

Step 5. Configuring Apache web server for WordPress.

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘wordpress.conf’ on your virtual server:

sudo a2enmod rewrite
touch /etc/apache2/sites-available/prosper.conf
ln -s /etc/apache2/sites-available/prosper.conf /etc/apache2/sites-enabled/prosper.conf
nano /etc/apache2/sites-available/prosper.conf

Add the following lines:

ServerAdmin [email protected]
DocumentRoot /var/www/prosper202/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common

Now, we can restart Apache web server so that the changes take place:

systemctl restart apache2.service

Step 6. Accessing Prosper202.

Prosper202 will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com or http://server-ip/ and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Congratulation’s! You have successfully installed Prosper202. Thanks for using this tutorial for installing Prosper202 on your Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official Prosper202 web site.

How To Install RabbitMQ on Ubuntu 16.04

Install RabbitMQ on Ubuntu 16

RabbitMQ is open source message broker software (sometimes called message-oriented middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ server is written in the Erlang programming language and is built on the Open Telecom Platform framework for clustering and failover. Client libraries to interface with the broker are available for all major programming languages.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation RabbitMQ on a Ubuntu 16.04 server.

Install RabbitMQ on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Installing Erlang.

Install Erlang using command:

wget http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc
sudo apt-key add erlang_solutions.asc
sudo apt-get update
sudo apt-get install erlang
sudo apt-get install erlang-nox

Step 3. Installing RabbitMQ.

First, Enable RabbitMQ application repository:

echo "deb http://www.rabbitmq.com/debian/ testing main" &gt;&gt; /etc/apt/sources.list

After the repository is added, we will add the RabbitMQ public key to our trusted key list to avoid any warnings about unsigned packages:

wget https://www.rabbitmq.com/rabbitmq-signing-key-public.asc
sudo apt-key add rabbitmq-signing-key-public.asc

Now we just need to run an update, and install the rabbitmq-server from our newly added package:

sudo apt-get update
sudo apt-get install rabbitmq-server

To start, stop, restart and check the RabbitMQ status, use the following:

# To automatic enable boot service:
systemctl enable rabbitmq-server

# To start the service:
systemctl start rabbitmq-server

# To stop the service:
systemctl stop rabbitmq-server

# To restart the service:
systemctl restart rabbitmq-server

# To check the status:
systemctl status rabbitmq-server

Step 4. Access RabbitMQ management console.

To manage your RabbitMQ server, you can use the rabbitmq-management plugin. This plugin allows you to manage and monitor your RabbitMQ server in a variety of ways, such as listing and deleting exchanges, queues, bindings and many more. To install the plugin, use the following command:

sudo rabbitmq-plugins enable rabbitmq_management

RabbitMQ will be available on HTTP port 15672 by default. Open your favorite browser and navigate to http://yourdomain.com:15672 or http://server-ip:15672 and complete the required the steps to finish the installation.

Congratulation’s! You have successfully installed RabbitMQ server. Thanks for using this tutorial for installing RabbitMQ on Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official RabbitMQ web site.

How To Install Drupal on Ubuntu 16.04

Install Drupal on Ubuntu 16

Drupal is an open-source and one of the most popular PHP based content Management System (CMS) platform for building personal blogs or big corporate websites. It has thousands of templates and plugins that are mostly free to download and install. Due to the stability of the base, the adaptability of the platform, and its active community, Drupal remains a popular choice after more than a decade on the scene.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Drupal on a Ubuntu 16.04 LTS (Xenial Xerus) server.

Install Drupal on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

sudo apt-get update
sudo apt-get upgrade

Step 2. Install LAMP (Linux, Apache, MariaDB, PHP) server.

A Ubuntu 16.04 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install all required PHP modules:

apt-get install php5 php5-mysql php5-gd php5-curl libssh2-php

Step 3. Installing Drupal.

First thing to do is to go to Drupal’s download page and download the latest stable version of Drupal, At the moment of writing this article it is version 8.1.1:

wget https://ftp.drupal.org/files/projects/drupal-8.1.1.zip

Unpack the Drupal archive to the document root directory in your server:

unzip drupal*.zip
cp -rf drupal*/* /var/www/html/

1

We will need to change some folders permissions:

chown www-data:www-data -R /var/www/html/
chmod -R 755 /var/www/html/

Step 4. Configuring MariaDB for Drupal.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

Next we will need to log in to the MariaDB console and create a database for the Drupal. Run the following command:

mysql -u root -p

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Drupal installation:

create database drupal;
grant all privileges on drupal.* to drupaluser@localhost identified by 'your_password';
flush privileges;
exit

Step 5. Configuring Apache web server for Drupal.

Create a new virtual host directive in Apache. For example, create a new Apache configuration file named ‘drupal.conf’ on your virtual server:

sudo a2enmod rewrite
touch /etc/apache2/sites-available/drupal.conf
ln -s /etc/apache2/sites-available/drupal.conf /etc/apache2/sites-enabled/drupal.conf
nano /etc/apache2/sites-available/drupal.conf

Add the following lines:

ServerAdmin [email protected]
DocumentRoot /var/www/html/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all

ErrorLog /var/log/apache2/your-domain.com-error_log
CustomLog /var/log/apache2/your-domain.com-access_log common

Now, we can restart Apache web server so that the changes take place:

systemctl restart apache2.service

Step 6. Accessing Drupal.

Drupal will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com or http://server-ip and complete the required the steps to finish the installation. Remember that you’ll need the database name, username and password you created earlier to connect. If you are using a firewall, please open port 80 to enable access to the control panel.
install-drupal
Congratulation’s! You have successfully installed Drupal. Thanks for using this tutorial for installing Drupal content management system (CMS) on Ubuntu 16.04 LTS (Xenial Xerus) system. For additional help or useful information, we recommend you to check the official Drupal web site.

You Might Also Like: How To Install WordPress on Ubuntu 16.04

How To Install LEMP on Ubuntu 16.04

Install LEMP on Ubuntu 16

A LEMP software stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Nginx web server (which replaces the Apache component of a LAMP stack). The site data is stored in a MySQL database (using MariaDB), and dynamic content is processed by PHP.

lemp stack install in ubuntu

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation LEMP stack (Linux, Nginx, MariaDB and PHP) on Ubuntu 16.04 server.

Install LEMP on Ubuntu 16.04

Step 1. First make sure that all your system packages are up-to-date by running these following apt-get commands in the terminal.

apt-get update
apt-get upgrade

Note: If another web server like Apache2 was installed in your system, remove it first to avoid conflicts. To uninstall Apache, run the following commands:

sudo service apache2 stop
sudo apt-get remove --purge apache2 apache2-utils apache2.2-bin apache2-common -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y

Step 2. Installing Nginx on Ubuntu 16.04.

Install Nginx with apt-get, which is the default package manager for Ubuntu:

sudo apt-get install nginx

Start Nginx service using the following command:

sudo systemctl start nginx

You can verify that Nginx is really running by opening your favorite web browser and entering the URL http://your-server’s-address, if it is installed, then you will see this:
nginx-default-page
The default web page for NGINX on Ubuntu 16.04

Step 3. Configure Nginx web server.

To get Nginx to work with PHP correctly, we need to make changes to the Nginx configuration file. This guide we will be using a simple Nginx config file:

sudo nano /etc/nginx/sites-available/default

Copy the following into your text editor:

server {
listen 80;
server_name your_domain_name.com;
root /usr/share/nginx/html;
index index.php index.html;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

Once you have finished editing the file restart Nginx with:

sudo nginx -t
sudo systemctl restart nginx

Step 4. Installing MySQL on Ubuntu 16.04.

To install MySQL in Ubuntu 16.04 run the following command:

sudo apt-get install mysql-server php5-mysql

Once complete, you can verify MySQL is installed by running the below command:

systemctl status mysql

By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:

mysql_secure_installation

Configure it like this:

- Set root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y

To log into MySQL, use the following command (note that it’s the same command you would use to log into a MySQL database):

mysql -u root -p

Step 5. Installing and Configuring PHP on Ubuntu 16.04.

Install PHP on the Ubuntu 16.04 with the following command to begin the install:

sudo apt-get install php php-fpm php7.0-mysql

Once the installation is finished, edit the server php.ini file and change the cgi.fix_pathinfo parameter value to 0. By default it will be commented out with a semi-colon and the value set to 1 which practically ensures that PHP will attempt to execute the closest file available when a requested PHP file can’t be found. This is a bad security practice, so let’s change it. Execute the below command:

nano /etc/php/7.0/fpm/php.ini

Now find the cgi.fix_pathinfo line, uncomment it and set the value to 0. Save and close the file.

Your server should restart Nginx automatically after the installation of both MySQL and PHP. If it doesn’t, execute this command:

sudo systemctl restart nginx

To test PHP, create a test file named info.php with he content below. Save the file, then browse to it to see if PHP is working:

nano /usr/share/nginx/html/info.php

Copy the following into your text editor:

<!--?php phpinfo(); ?-->

Try to access it at http://your_server_ip/info.php . If the PHP info page is rendered in your browser then everything looks good and you are ready to proceed further.

installing-lemp-ubuntu-16-04
Congratulation’s! You have successfully installed LEMP stack. Thanks for using this tutorial for installing LAMP (Linux, Nginx, MySQL and PHP) in Ubuntu 16.04 system. For additional help or useful information, we recommend you to check the official Nginx, MySQL and PHP web site

You Might Also Like: How To Install LAMP Stack on Ubuntu 16.04