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.
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.
Install LEMP Stack on Ubuntu 15.10
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:
- Ubuntu 15.10 Desktop Installation Guide
- Ubuntu 15.10 Server Installation Guide
- Configure Static IP Address and DNS in Ubuntu 15.10
Step 1: Installing Apache Web Server
1. Now that you have the “L” in LAMP it’s time to proceed to the “A” – Apache. It can be easily installed by running:
$ sudo apt-get install apache2
When asked to confirm the installation, press
"y" followed by enter.
2. Once the installation is complete, you can test your installation by going to:
To find your IP address, you can use command such as:
$ ifconfig -a
3. Now copy/paste the IP address in your browser. You should see the following page:
4. The default location for website files (also know as document root) for Apache is:
The Apache configuration file is located at:
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
6. When the install is complete, you can start and the statu of MariaDB service with:
$ sudo service mysql start $ sudo service mysql status
7. If you want to secure your MariaDB installation you will need to run:
$ sudo mysql_secure_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):
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:
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:
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:
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
13. You will now need to restart Apache so it can see the changes you just made and run PHP.
$ sudo service apache2 restart
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
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:
You should see the following page:
If you need to change the PHP settings, you should edit the following file:
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.