This guide assumes you have already installed Ubuntu 16.04.

1. Start by installing openssh if you have not already.

$ sudo apt-get update
$ sudo apt-get install openssh-server

2. Next install apache

$ sudo apt-get install apache2

Enable apache

$ sudo systemctl enable apache2

Start apache

$ sudo systemctl start apache2

You can now check the status of apache to verify it is running

$ sudo systemctl status apache2

3. Now we are ready to move onto installing SQL, there are multiple flavors of SQL that you can install. I prefer mysql over mariadb, because of this I will be walking you through the MYSQL install.

Start by using apt-get to download and install the package

$ sudo apt-get install mysql-server mysql-client

During the install a box will appear asking for you to create your “root” MYSQL password, just leave this blank for now. We will be running a script after installation to secure MYSQL.

Once the installation has completed run the following command to secure MYSQL

$ mysql_secure_installation

Here is how I answer the questions in this script:

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MYSQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MYSQL to secure it, we'll need the current
password for the root user.  If you've just installed MYSQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MYSQL
root user without the proper authorization.
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MYSQL installation has an anonymous user, allowing anyone
to log into MYSQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] 
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] 
 ... Success!
By default, MYSQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] 
 - Dropping test database...
ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist
 ... Failed!  Not critical, keep moving...
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] 
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MYSQL
installation should now be secure.
Thanks for using MYSQL!

Congrats we are almost done! Next we need to install php

$ sudo apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0

Next restart the apache service

$ sudo systemctl restart apache2

Verify everything is working by visiting http://ip-address-of-apache-server

Tagged: