Install LAMP (Linux, Apache, MariaDB and PHP) in Ubuntu 15.10

LAMP stack is the combination of the most frequently used software packages to build dynamic websites. LAMP is an abbreviation that uses the first letter of each of the packages included in it: Linux, Apache, MariaDB, PHP.

Install LAMP on Ubuntu 15.10

You can use LAMP to build awesome websites with platforms such as WordPress or Joomla for example.

If you are PHP developer you can install LAMP on your computer and test your code locally. This doesn’t mean that LAMP cannot be used in production environments as well.

If you are looking for LEMP (Linux, Nginx, MariaDB and PHP) environment for your server or computer, you can go through below article.

In this tutorial I am going to show you how to install and configure LAMP in Ubuntu 15.10. The guide assumes that you have already installed Ubuntu 15.10. If you have not installed already, you can refer to our guides here:

Step 2: Installing MariaDB Database

5.MariaDB is a relational database management system. It is a community fork of the probably better known MySQL database server. It is meant to remain free under the GNU/GPL. This is why it is now the preferred choice for relational database management system.

Installing it in Ubuntu 15.10 can be completed with:

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

Install MariaDB in Ubuntu 15.10

6. When the install is complete, you can start and the statu of MariaDB service with:

$ sudo service mysql start
$ sudo service mysql status

Start MySQ Database

7. If you want to secure your MariaDB installation you will need to run:

$ sudo mysql_secure_installation

Secure MySQL Installation

8. You will be asked to enter the current MariaDB root password. The default password is empty so you can simply press enter. After that you can enter the new root password (twice):

Set MySQL root Password

9. After that you can disable anonymous accounts for the MySQL service. It is strongly recommend that such accounts are disabled in production environment.

10. The next step in securing your MariaDB installation is to disable remote access to your databases from root user. This option should be disabled unless you have a good reason for using root. Instead, you can create privileged users later:

Remove MySQL Anonymous User

11. When installing MariaDB it creates a default “test” database, you can safely remove that when asked to:

Finally to make sure that the changes are saved, you will ned to reload the privileges:

Remove MySQL test Database

You are done securing your your MariaDB configuration.

If you wish to modify the settings of your MariaDB server, you will need to edit the following file as root:

/etc/my.cnf

Step 3: Installing PHP Programming Language

12. The final step in our tutorial is completing the installation of PHP. It is an programming language used to developed dynamic websites. Larger part of the websites in the world wide web are built using this language. Many content management systems such as WordPress and Joomla are written in this language!

Installing PHP on Ubuntu 15.10 can be completed by running:

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

Install PHP in Ubuntu 15.10

13. You will now need to restart Apache so it can see the changes you just made and run PHP.

$ sudo service apache2 restart

Restart Apache Web Sever

14. Finally it’s time to test our settings. You can create a test PHP file which will show us the current PHP configuration. For that purpose create a file called info.php in:

/var/www/html/

For example you can use:

sudo vi /var/www/html/info.php

Insert the following code in the file:

<?php
phpinfo()
?>

15. Finally save the file by pressing Esc and “:wq“. Now to verify that your PHP code is properly executed, open:

http://your-ip-address/info.php

You should see the following page:

Check Php Info

If you need to change the PHP settings, you should edit the following file:

/etc/apache2/php5/php.ini

Remember that each time you change the PHP settings, you will need to restart Apache so the changes can take effect. Apache can be restarted with:

$ sudo service apache2 restart

Thats it! You now have all the tools required to build a dynamic website, learn programming or create your own hosting server.

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.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.