Benefits of using a LAMP stack
- The use of PHP and MySQL allows newcomer developers to get started building web applications at scale.
- LAMP stack technologies are frequently updated, making them more secure.
- They have a lot of support from open source software (O.S.S) community.
Prerequisites (at least 1 of the following)
A. Virtual Machine running Ubuntu 16.04 LTS
B. Have signed up for web hosting or already own Ubuntu 16.04 LTS instance
If you haven’t done so already, download a fresh copy of Ubuntu 16.04 LTS to get started.
Check Ubuntu version
The output should be equal or similar to
Distributor ID: Ubuntu Description: Ubuntu 16.04.2 LTS Release: 16.04 Codename: xenial
Update the list of available packages and their versions
sudo apt-get update
Update available packages
sudo apt-get upgrade
sudo apt-get install apache2
sudo apt-get install mysql-server mysql-client
You will be prompted to setup the root user password to be used with MySQL. It is important that you remember it.
You can login into MySQL as root using the following command:
mysql -u root --password=YOUR_DB_PASSWORD
sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0-xml php7.0-gd
Check php info
sudo apt-get install vim sudo vim /var/www/html/testphp.php
Add the following line to the file:
<?php phpinfo(); ?>
Restart apache2 service
- On Ubuntu 15.10/15.04 and greater versions:
sudo systemctl restart apache2
- On Ubuntu 14.10 and lower versions:
sudo service apache2 restart
Validate php install
On your browser of choice, navigate to http://localhost/testphp.php (swap the word localhost with your ip-address).
It will display all the details about php such as version, build date and commands etc.
And there you go, you have succesfully installed LAMP stack on your Ubuntu 16.04 Server.
If you enjoyed this blog post or found it helpful in any way, make sure to follow me on Twitter to find out when a new one is available.