By Arman Ali
There are the two most popular stacks available in the current market "LAMP Stack" and "LEMP Stack".
Both stacks have contained a group of open-source software like - Linux, MySQL, PHP.
In this tutorial, we are going to install LAMP Stack on Ubuntu 20.04.
To complete this guide, You will need to have an Ubuntu 20.04 installed on VPS or Cloud Instance. We will be using an Alibaba Cloud Elastic Compute Service (ECS) instance for our guide.
Apache web server is one the most famous web server in the market. it captured approx 33.5% of the websites on the internet. Apache is being developed and maintained by the Apache Foundation.
In order to install Apache on your Ubuntu 20.04 First -
Login to your server via SSH terminal.
ssh username@you-IP-address
Update the Ubuntu's package manager
sudo apt-get update
Now, Use this command to install Apache.
sudo apt install apache2
Press Y for yes and press Enter.
We now have successfully installed apache on our server.
You can confirm this by visiting your IP to see the holding page Apache.
http://your-IP-address
Now we need to install MySQL on our instance. MySQL is a widely popular database management system.
In order to install MySQL, we need to run this command
sudo apt install mysql-server
Press Y for yes and then press Enter.
It is time to secure our MySQL server. Use this command to secure the MySQL server.
sudo mysql_secure_installation
It will ask for VALIDATE PASSWORD PLUGIN
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
If you are planning to install WordPress on this LAMP Stack. Leave this thing otherwise it will conflict later with some plugins in WordPress.
Press Enter to No.
Now, this will ask to set a new root password for MySQL. You should enter a very secure password. confirm your password again and press Enter.
Now, this will ask you to remove anonymous users from MySQL.
Type Y and press Enter.
Now, this will ask you to Disallow root login remotely?
Press Y and Enter
Now, this will ask you to Remove test database and access to it?
Press Y and Enter
Finally, this will ask you to Reload privilege tables now?
Press Y and Enter
You have successfully secured your MySQL server.
PHP will help our server to display dynamic content to end-users. you can install PHP by using this command.
sudo apt install php libapache2-mod-php php-mysql
Press Y and Enter
This will install PHP and some default PHP extension on your server if you want to use some specific PHP extensions you can install that particular extension by using this php-extentsionname
For example, we want to install a PHP-mbstring extension We have to run this command
sudo apt install php-mbstring
Press Y and Enter
All Done!
Restart the Apache web server to load PHP by using this command.
sudo systemctl restart apache2
To test whether PHP is working on your server or not we can create an info.php
file in the root directory of your web server with a PHP info script.
sudo nano /var/www/html/info.php
This will open a nano
text editor in your terminal
Now Paste this script
<?php
phpinfo();
Now press CTRL+X
, Y
, and Enter
to save this file.
Now you can visit your IP Address with info.php to see your info file like this.
http://your-IP-adress/info.php
You should get a detailed PHP info page as shown below.
Congratulations! We have successfully installed LAMP Stack on Ubuntu 20,04 LTS.
Now your LAMP stack is now ready on Ubuntu 20.04 you can now start budding/deploying your dynamic or static site on this LAMP stack.
If you have any questions feel free to ask in the comment section. we will surely reply to them.
Quick Guide! How to Install a Free SSL Certificate on NGINX Web Server
francisndungu - August 22, 2021
Hiteshjethva - May 29, 2021
Alibaba Cloud Community - March 23, 2022
Alibaba Clouder - April 26, 2019
Alibaba Clouder - April 26, 2019
Alibaba Clouder - February 14, 2020
Alibaba Cloud Linux is a free-to-use, native operating system that provides a stable, reliable, and high-performance environment for your applications.
Learn MoreA fully-managed Apache Kafka service to help you quickly build data pipelines for your big data analytics.
Learn MoreAnalyticDB for MySQL is a real-time data warehousing service that can process petabytes of data with high concurrency and low latency.
Learn MoreRealtime Compute for Apache Flink offers a highly integrated platform for real-time data processing, which optimizes the computing of Apache Flink.
Learn More