A LAMP stack is an open source software stack for building dynamic websites and web applications. And this guide is about the LAMP Stack on Ubuntu system. Basically, LAMP is an acronym of its own components, Linux, Apache, MySQL, and PHP. Each component has it’s own functionally, Linux as the operating system, Apache as HTTP web server, MySQL to store all site data, and dynamic content handled by PHP.
A LAMP stack becomes one of the most popular software stacks for web applications technology, especially the LAMP stack on Ubuntu System. It has been used for the most PHP web application frameworks such as Laravel, YII Framework, CodeIgniter etc. And most content management system such as WordPress, Magento, Drupal, and Joomla uses it too.
In this guide, we’re going to show you install the LAMP Stack on Ubuntu 18.04 Bionic beaver.
In order to complete this guide about LAMP Stack on Ubuntu system, ensure you have the latest version of Ubuntu Server 18.04 with basic setup and configuration of the ufw firewall and sudo root privileges. The basic initial setup ubuntu server 18.04 can be done on this link.
Step 1 – Installing Apache Web Server
Apache HTTP web server is one of the most popular web servers on the internet. Widely used by large websites such as Paypal.com, bbc.com, bbc.co.uk, steam store etc. In short, Apache web server is a great choice to host your dynamic websites and web applications.
First of all, ensure all repositories on the Ubuntu system is up to date. Or you can run the apt command below to update system repositories.
sudo apt update
Now install Apache with the following apt command.
sudo apt install apache2 -y
Once the Apache installation is complete, you will need to add Apache to the ufw firewall application list.
Check available applications on the ufw firewall.
sudo ufw app list
And you will be shown three different profile for Apache, add the ‘Apache Full’ to for opening both HTTP and HTTPS protocols.
sudo ufw allow in "Apache Full"
After that, open your web browser and type the server IP address on the address bar.
After installing Apache web server, we’re moving forward to install one of the most popular RDBMS (Relational Database Management System) MySQL server.
Install MySQL server using the following apt command.
sudo apt install mysql-server mysql-client -y
When the installation is complete, we need to secure the MySQL deployment by configuring the root password of the MySQL server. Simple, run the following command.
And you will be prompted about various configurations for securing the MySQL deployment.
Would you like to setup VALIDATE PASSWORD plugin? Y
Type ‘Y’ to yes.
Now you need to choose between three password policies, 0 for LOW, 1 for MEDIUM, and 3 for STRONG.
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2
We recommend using the ‘STRONG’ password policy ‘2’. Then type the strong password that you’re comfortable and type ‘y’ for yes to confirm.
After that, type ‘Y’ again for all the rest.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
And the MySQL server configuration is complete. Test by logging in to the MySQL with the user root and your password, then create a new MySQL user for your applications.
mysql -u root -p
TYPE YOUR PASSWORD
Create a new MySQL user by running the following queries.
At this point, you have successfully logged in to the MySQL and created a new mysql user.
Step 3 – Installing PHP 7.x
PHP is one of the most server scripting languages that has been used on the internet. It can run PHP scripts, connect to the MySQL database, and generate contents of web applications for you through a web browser.
By default, the new version of ubuntu server has a default PHP 7.2 for installation. And for this case, we’re going to install PHP 7.2 with some basic modules for basic PHP web applications.