This tutorial will show you how to install LAMP (Linux, Apache, MySQL and PHP) on Ubuntu 16.04. As you know, Apache, MySQL and PHP is an essential application to build a powerful web server on top of the most popular Linux distribution, Ubuntu. Installing LAMP on Ubuntu 16.04 is not difficult. With some easy instructions, you can have a powerful web server on your Ubuntu 16.04.
Steps to install LAMP Server on Ubuntu 16.04.
A. Install Apache web server on Ubuntu 16.04
First thing, we need to install Apache web server on our Ubuntu 16.04. For example, I am installing Apache on my Ubuntu 16.04 droplet hosted on DigitalOcean. You may have a cloud computer/server at a low price ($5 per month) on DigitalOcean.
Open Terminal and login as root then execute this command to install Apache web server
apt-get update apt-get install apache2
After installing apache2, we need to configure the ufw firewall. This to make sure that the firewall allows http and https traffic to our server. Execute this command to view ufw profile available
ufw app list
You will see available applications such as:
Now try to look at the Apache Full profile
ufw app info "Apache Full"
Profile: Apache Full
Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
Now enable the profile:
ufw allow in "Apache Full"
Now check if the web server is ready.
Open web browser and type:
Congratulation, the web server is now running on Ubuntu 16.04.
B. Install MySQL Server
Next step is to install MySQL Server, the most popular relational databases out there. Installing MySQL Server on Ubuntu 16.04 is pretty easy. Still in Terminal console, execute this command to install MySQL Server on Ubuntu 16.04.
apt-get install mysql-server
During installation you will be asked to create a new password for MySQL root user.
Next step is to secure our MySQL installation. Execute this command below:
You will be asked to enter the root password and also, you will be asked to enable the validate password plugin. Its not mandatory, as long as your password is strong enough.
Once finished, you can check if MySQL Server is ready. Make sure its active, indicate that our MYSQL Server is up and running.
service mysql status
C. Install PHP
To install php, use this command below
apt-get install php libapache2-mod-php php-mcrypt php-mysql
Restart Apache web server to complete
service apache2 restart
Now, LAMP server is up and running on Ubuntu 16.04. Start build your website!