Setting Up LAMP (Linux, Apache, MySQL/MariaDB, PHP) and PhpMyAdmin on Ubuntu 15.04 Server

LAMP stack is a combination of the most frequently used open source software related to web service. This group includes Apache Web Server, MySQL/MariaDB and PHP. Often the MySQL/MariaDB databases are managed through database management tool such as phpMyAdmin.

This article will guide you through the process of installing LAMP on Ubuntu 15.04 based server.

Requirements:

Before we start, there are few requirements that should be met:

  1. Minimal installation of Ubuntu 15.04.
  2. SSH access to the server (if you do not have direct access to the server).
  3. If the machine will be used as server you should make sure it has a static IP address configured.

Step 1: Set Server Hostname and System Update

1. As soon as your Ubuntu 15.04 server is up and running, access it over SSH and setup the hostname. This can be easily achieved by using:

$ sudo hostnamectl set-hostname your-hostname.com
$ hostnamectl
Set Hostname for System
Set Hostname for System

Of course you should change “your-hostname.com” with the actual hostname that you will use.

2. To make sure your system is up to date, run the following command:

$ sudo apt-get update && sudo apt-get upgrade
Upgrade Ubuntu 15.04
Upgrade Ubuntu 15.04

Step 2: Install Apache Webserver

3. Apache is the most frequently used webserver and it hosts most of the sites available online. To install Apache on your server, you can simply type the following command:

$ sudo apt-get install apache2
Install Apache on Ubuntu 15.04
Install Apache Web Server

You can now start Apache by running:

$ sudo service apache2 start

Start Apache Service
Start Apache Service

4. To verify if the web server is working correctly, open http://server-ip-address in your browser. You can find your server IP address by running:

$ ifconfig –a
Check IP Address
Check IP Address

When you access the IP address in browser, you should see a page similar to this:

Apache Default Page
Apache Default Page

Step 3: Install PHP with Modules

5. PHP stands for Hypertext Preprocessor . It is a powerful programing language used mostly for generating dynamic web pages frequently used with databases. Notice that PHP code is executed by the web server.

To install PHP simply run the following command:

$ sudo apt-get install php5 php5-mysql php5-mcrypt php5-gd libapache2-mod-php5
Install PHP on Ubuntu 15.04
Install PHP and PHP Modules

6. To test your PHP installation, navigate to the web server root directory and create and open a file named php_info.php:

$ cd /var/www/html/
$ sudo vim php_info.php

Insert the following code:

<?php phpinfo(); ?>

Save the file and load it in your browser by typing http://your-ip-address/php_info.php. You should see the output of the phpinfo() function that will provide information about your PHP setup:

Check PHP Info
Check PHP Info

You can install more PHP modules later. To search for more modules simply use:

$ sudo apt search php5

Step 4: Install MariaDB Server and Client

7. MariaDB is a relatively new database management system that is community-developed. It is a fork of MySQL, intended to remain free under the GNU GPL. The project is led by the original developers of MySQL due to Oracle gaining control over MySQL distribution. It basically provides the same functionality as MySQL and there is nothing to fear here.

To install MariaDB in Ubuntu 15.04 run the following command:

$ sudo apt-get install mariadb-client mariadb-server
Install Mariadb Server
Install Mariadb Server

8. During installation, you will not be asked to setup password for the MariaDB root user. To do this, you will need to issue the following set of commands:

$ sudo mysql –u root
$ use mysql;
$ update user set plugin='' where User='root';
$ flush privileges;
$ quit
Configure MySQL
Configure MySQL

Now the root user can be secured by using the following command:

$ mysql_secure_installation

Secure Mysql Database

Secure Mysql Database

Step 5: Install PhpMyAdmin

9. PhpMyAdmin is a web interface through which you can easily manage/administer your MySQL/MariaDB databases. The installation is really simple and can be completed with the following command:

$ sudo apt-get install phpmyadmin
Install PhpMyAdmin on Ubuntu 15.04
Install PhpMyAdmin

Upon installation you will be asked to select the web server you are using. Select “Apache” and continue:

Configure PhpMyAdmin for Apache
Configure PhpMyAdmin for Apache

10. Next you will be asked if you wish to configure phpMyAdmin with dbconfig-common. Select “No” as shown in the screenshot:

Configure PhpMyAdmin
Configure PhpMyAdmin

At this point your phpMyAdmin installation is complete. To access it you can use http://your-ip-address/phpmyadmin:

To authenticate you can use the MySQL root user and the password that you setup earlier for that user.

PhpMyAdmin Login
PhpMyAdmin Login
PhpMyAdmin Dashboard
PhpMyAdmin Dashboard

Step 6: Start LAMP at System Boot

11. Even though the installers should have configured both Apache and MariaDB to start automatically upon system boot, you can just in case run the following commands to ensure that they are enabled:

$ sudo systemctl enable apache2
$ sudo systemctl enable mysql
Enable Services at Boot
Enable Services at Boot

You can perform a system reboot to ensure that all services start normally as expected.

That is all. Your Ubuntu 15.04 server is now running the LAMP stack and you are ready to build or deploy your web projects on it.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Marin Todorov
I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply
  1. Thank you for your help :) I usually use windows so I bought a windows KVM server and got it stuck, so they recommended me Ubuntu KVM server if I was going to release the game there and I did that and got a refund on the windows shit. and its working like a charm. Thank you for sharing :D

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.