Lamp is an example of web server stack. Mostly when people use windows as its OS then it’s called WAMP, similarly if you employ Solaris it’ll become SAMP and MAMP for Macintosh.
Sometimes people use Pearl or python as programming language .In order to successfully how to install LAMP on Ubuntu 18.04, you need to make sure, you have root privileges or you have the privilege to Sudo commands to run the commands throughout this article.
Ubuntu is a Linux distributed operating system then the L in the Lamp is already taken care of if you are using Ubuntu as your operating system. If you don’t have it then you need to install Ubuntu as your operating system.
Table of Contents
STEP 1: UPDATE
First thing you need to check is that your packages are updated. for that you need to type the following commands in your terminal.
sudo apt update
sudo apt upgrade
Press ‘y’ to finish the procedure
sudo apt install apache2 apache2-utils
Press ‘y’ to finish the procedure
it will ask you your password as only the administrator have the rights to use the root privileges.
Step 2: install Apache
You can type the following command to install apache2 in your PC. This command will make sure that all the necessary dependencies and packages are installed.
sudo apt install -y apache2 apache2-utils
It will take a few minutes to complete the installation then you can check if apache works or not.
To check you can either go to your web browser and search localhost if it doesn’t work try searching with the IP 127.0.0.1
you will receive a confirmation page.
Or you can check the status if Apache is working or not through typing the command:
systemctl status apache2
if this doesn’t work then most probably your firewall is preventing the traffic and you need to adjust it. Ubuntu uses UFW to prevent unnecessary data from interfering and only connection to specific services is allowed.
You need to allow Apache through your firewall.
First check the list of application profile for Apache by typing
sudo ufw app list
Now enable “Apache full” to allow in UFW.
sudo ufw allow in "Apache Full"
you should see the confirmation page that means you are ready to go!
Step 3: Install MySQL/MariaDB
If you have your web server installed then you are ready to install MySQL.
For that you need to simply type in
sudo apt install mysql-server
enter ‘Y’ to continue installation. This command will make sure that all the necessary things are installed to get your database working.
After the installation is completed then package configuration screen or in the terminal will be displayed asking you to choose a password for your database.
You can leave it blank, your password will simply become “” but its recommended that you choose a password.
Keep entering ‘Y’ to reach the end of the terminal. If there were no error throughout the installation then MySQL is setup!
You can type the following command to check if you MySQL is working.
mysql -u root -p
Install MariaDB by typing
sudo apt install mariadb-server
MariaDB will install automatically and you can check it by viewing its status
sudo systemctl status mariadb
Step 4: install PHP
As PHP is a strong language and can retrieve, communicate to your database and process dynamic content quiet easily
sudo apt-get install software-properties-common
Ater the repository is installed update and install php 7.4
sudo apt-get update
sudo apt-get install -y php7.4
once your PHP is installed and running then you can even add PHP modules.
to install any module, you type:
sudo apt-get install #name of the module
create a new file and open it.
sudo nano /var/www/test.php
write any php command in your test, php and run it. If its executed then your php is working.
Try restarting apache so the alteration can take place.
sudo service apache2 restart
access your php file by typing 127.0.0.1/test.php
LAMP is useful to use when developing as it is a whole package. installing LAMP in Ubuntu has its own perks like involving other open source components to make development easy.
LAMP and Ubuntu are a powerful combination that makes software developing easier and extensive.