
How To Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu 18.04
Introduction
LAMP (an acronym meaning Linux, Apache, MySQL, PHP) is an open-source software stack enabling dynamic websites and applications to be built. Together, they provide the tools needed to develop most of what you’d typically need in a website or online service. We have provided a simple shell script you can get with the below command that should run fine on most standard installs of Ubuntu 18.04. Please note, you will need to make the script executable first before it will run.
Console
wget https://www.vmsimple.com/downloads/u18_lamp.sh
If you have issues with the script , or want to manually install this to learn more about how this is done, please read on.
Step 1 — Installing Apache and Updating the Firewall
Apache is the defacto standard web server for websites, with over 30% of all sites using it as of 2019. It is well documented, and has a robust community around it you can tap into for support or tools and modifications.
Install Apache using Ubuntu’s package manager, apt
:
Console
sudo apt update
sudo apt install apache2
Running these commands as sudo will execute them with root privileges. If you are not signed in as root, the system will prompt you for your password and check if you have sudo privileges. If you do not, this will fail. You need to run this with root privileges, or as root.
Once you’ve successfully entered the commands, apt will tell you which packages it needs to install and how much space they will need on your storage. Press Y and hit Enter to continue, and the installation should complete without issue.
Adjust the Firewall to Allow Web Traffic
Allow incoming HTTP and HTTPS traffic for Apache in Ubuntu’s default Firewall Application, ufw:
Console
sudo ufw allow in "Apache Full"
It is advised to make sure everything is running properly at this point. You can do this by opening your servers IP address in any web browser and making sure Apache is serving web pages properly. You should see the default Apache web page for Ubuntu, which should look similar to the below image:

If you see this page, then your web server is now correctly installed and accessible through your firewall.
Step 2 — Installing MySQL
Now that you have your web server up and running, it is time to install MySQL. MySQL is what’s known as a Relational Database Management System (RDBMS). It is the most widely used data storage engine in the world, and should serve well for a default database system for most applications and sites.
Again, use apt to acquire and install this software:
Console
sudo apt install mysql-server
This command, too, will show you a list of the packages that will be installed, along with the amount of disk space they’ll take up. Enter Y
to continue.
Step 3 — Installing PHP
If Apache let’s you display things, and MySQL let’s you store data, PHP is the bridge that makes everything run and actually do things. PHP is a widely used server side scripting language. It will be used to connect to your database, get information, process the information, and hand it off to Apache to be displayed to your users.
As usual, we install this using the apt system. You also are installing several helper packages that will link you Apache and MySQL install to this PHP install. Run the following commands:
Console
sudo apt install php libapache2-mod-php php-mysql
This should install PHP without any problems.
Conclusion
Thank you for checking out this guide. If this guide was useful, please consider liking us on Facebook or Signing Up for updates to our blog to see when we post new guides or news.
Thanks for this!!!