LAMP is a reference to open source most frequently used software related to web services. The L in LAMP stands for Linux, A for Apache2 Web Server, M for MySQL or MariaDB database server and the P for PHP web service scripts. Combining and installing these allows anyone to run blogs, websites or web services that support LAMP.
This brief tutorial is going to show you how to enable LAMP on Ubuntu 15.04 servers. It should be easy and if you’ve installed it before in previous versions of Ubuntu, than this should be a cakewalk. Before getting started, please make sure you have Ubuntu 15.04 installed with root access to your server.
When you’ve verified everything and ready, run the commands below to first update your server and remove unnecessary programs and services.
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
After updating your system, if prompted to restart, please do. After restarting, login and run the commands below to install Apache2 Web Server.
- Installing Apache Web Server
sudo apt-get install apache2
After installing Apache2, run the commands below to start the web server.
sudo service apache2 start
At this time, if you browse to the server using its IP address, you’ll see Apache2 default page for Ubuntu. This how you also tell the server is up and functioning.
- Installing PHP with Modules
The next step is to install PHP as well as its module to enable PHP apps or web services to function. There are hundreds of PHP modules, but these few will get most web services started. To install PHP and other modules, run the commands below
sudo apt-get install php5 php5-mysql php5-curl php5-gd php5-snmp php5-mcrypt php5-tidy php5-xmlrpc libapache2-mod-php5
After installing the above modules, go to Apache root directory. It can be found at /var/www/html in Ubuntu. There create a file called phpinfo.php. Then in that file, add the lines below.
<?php
phpinfo();
?>
Save the file, restart Apache and browser to the server IP address followed by phpinfo.php. (ex. http://192.168.100.1/phpinfo.php). There you’ll find PHP information page. This is how you also know PHP is functioning.
- Installing MySQL Server and Client
Finally, the last piece of the puzzle is MySQL database server. Even though most open source enthusiasts are moving towards MariaDB and leaving MySQL, we’re going to be installing MySQL anyway. It’s still the most popular open source database server out there. To do that, run the commands below.
sudo apt-get install mysql-server mysql-client
After installing the database server, you can started it using the commands below, if it’s hasn’t already started.
sudo systemctl start mysql
When it’s started, run the commands below to configure the database server.
sudo mysql_secure_installation
When prompted, follow the options below
Next, choose Yes for the rest of the prompts until you’re done.
- Enter current password for root (enter for none): Type root password
- Change the root password? N
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
Restart Apache2 and you’re done.
At this time, Apache2, PHP5 and other modules and MySQL database server should be installed and functioning. You Ubuntu server is ready for any opensource application that support the LAMP stack.
Other setup might might still be needed to get your applications to function properly.
To enable automatic startup for Apache2 and MySQL, run the commands below
sudo systemctl enable apache2
sudo systemctl enable mysql
That’s it! Enjoy!