Installing LAMP with MariaDB and PhpMyAdmin on Ubuntu 14.04


In this post I’m recreating Tero Karvinen’s Linux test for his class he made in 2012.

The assignment

Me Karttakatu Oy:ssä teemme karttoihin liittyviä weppisovelluksia. Olemme muutaman hengen yritys.

Asenna työasema, jolla tavallisimmat toimistotyöt onnistuvat (weppisurffailu, tekstinkäsittely). (Asentuessa voit käydä kommentoimassa kavereiden blogeja).

Työntekijämme ovat Einari Vähäkäähkä, Pekka Winha, Åke Andersson ja Leila Laila. He haluavat kehittää PHP-kotisivuja etäkäyttöyhteydellä. Asenna tarvittavat palvelut ja tee esimerkkisivut.

Asenna kaikkien käyttäjien käyttöön skripti (shell script) nimeltä “mystatus”, joka näyttää vapaan levytilan (df -h) ja koneen ip-osoitteen.

Tähtäätkö huipputulokseen? Pekka Winha haluaa käyttää MySQL tietokantaa. Asenna hänelle MySQL-tietokanta ja siihen PhpMyAdmin-weppiliittymä.

Installing Xubuntu on VirtualBox

For the installation part, I decided to use VirtualBox with 768MB RAM and 8GB fixed hard drive, although it would be good to do this on hardware, but I don’t have any unused hardware in my grasp and I don’t see it so important to do a dual boot solution.

I downloaded the Xubuntu 14.04.3 LTS (Trusty Tahr) X64 ISO image and inserted it as a virtual drive to my new virtual Linux.

Adding the users

As described in the assignment, I needed to add users for the system. This was simple with the adduser command.

sudo adduser vahakein
sudo adduser winhapek
sudo adduser anderake
sudo adduser lailalei

We have the L, now we need the AMP

First thing we need to do is update the apt source list.

sudo apt-get update


To the A. To kick off the installation of Apache, I needed to run this command:

sudo apt-get install apache2

It installed painlessly, but it did prompt me about setting up a FQDN (Fully qualified domain name), which I decided that I don’t need for the assignment.

Configuring Apache

I’m configuring Apache to enable users to use their own directory as their website using Apache’s module called userdir. First, I needed to enable the module like this.

sudo a2enmod userdir
sudo service apache2 restart

Then, to create public_html folders for every user, I needed to create the folder in ‘/etc/skel’ and change it’s permissions to allow web users to open and read the files.

sudo mkdir /etc/skel/public_html
sudo chmod 0755 /etc/skel/public_html

Next I needed to enable PHP to run in home directories. I opened the apache php configuration file

sudo nano /etc/apache2/mods-available/php5.conf

And located these lines

 <IfModule mod_userdir.c>
     <Directory /home/*/public_html>
         php_admin_value engine Off

Now I needed to comment out the ‘php_admin_value engine Off’ like this.

<IfModule mod_userdir.c>
     <Directory /home/*/public_html>
#        php_admin_value engine Off

Now I needed to reload the settings

sudo /etc/init.d/apache2 reload

Now it works! Let’s try it out:

cd /home/miro/public_html
nano index.html
    echo 'Hello World!';

Now when I navigate to ‘http://localhost/~miro/index.php‘ it reads ‘Hello World!


To the M. While the assignment told me to go with MySQL, I decided to use my favourite fork of it, the MariaDB.

sudo apt-get install mariadb-server

It prompted the root password for the MariaDB server’s root user.

Now to complete the installation and to make it secure:

sudo /usr/bin/mysql_secure_installation

I basically answered yes to everything, except for changing root password, because I had set it already.

To try it out, it launches the same way as MySQL

mysql -u root -p


To the P. Installing PHP in one simple command, first the PHP version 5 itself, a module for MySQL and a module for Apache to make it all work together.

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

Installing phpMyAdmin

To kick off the installation of phpMyAdmin, use this command

sudo apt-get install phpmyadmin

While installing it prompted first to select php5, then it prompted me to ask permission and the password to install its own database to make it functional. It also asked for the new phpMyAdmin password.

Then to configure it, I opened

sudo nano /etc/apache2/apache2.conf

and scrolled to the bottom of the file and added this line

Include /etc/phpmyadmin/apache.conf

After that just a simple restart was required and it worked.

sudo service apache2 restart

To try it out, I can logged in to phpMyAdmin at ‘http://localhost/phpmyadmin/’

Creating a shell script file

I needed to create a shell script file that tells the user how much space it has left and it’s current IP address.

What every shell script starts with is ‘#!/bin/bash’ and maybe a name after it. Then some clarification with ‘echo’ and the commands I needed.

# Mystatus

echo "Free disk space:"
df -h
echo "IP address:"
hostname -I

I saved this file to /etc/skal to make it available on all users.

To run it, I just need to type


In my home directory.

I used a digital ocean’s guide, a ubuntuserverguidethis shell script guide and this phpmyadmin guide to get along.


Miro Metsänheimo

A software developer from Finland born in -92. I'm passionate about computers and technology. Feel free to message me about anything!


Leave a Reply

Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin