What is LAMP???
LAMP is an open source Web development platform that uses Linux as the operating system, Apache as the Web server, MySQL as the relational database management system and PHP as the object-oriented scripting language.
I am using DigitalOcean for creating the VPS but you can use any service provider of your choice. As long as the operating system of your server is Ubuntu, the following steps will work to install LAMP on your server.
Installing Apache
Apache is an amazing web server and is the most commonly used Web server on Linux systems.
sudo apt update
The above command updates the package lists for upgrades. Let's run it to ensure that we install the latest versions of the packages. To install Apache, run the following command
sudo apt install apache2
Press Y when prompted and the installation will finish after a while. To allow Apache through the firewall use the following command:
sudo ufw allow in "Apache Full"
You can now go to the server URL (IP address of your VPS) and the apache2 default page will be displayed on the screen.
If you can see the above default page, then you have successfully installed Apache on your sever.
Installing MySQL
MySQL is a very popular and open source database that can be used with almost any application to store data effectively.
Execute the following command to install MySQL.
sudo apt install mysql-server
Confirm the installation by pressing "y" when prompted.
One the installation is done, you should be able to login into MySQL console by using "sudo mysql
". To exit the mysql console, use "exit
" command.
Installing PHP
sudo apt install php libapache2-mod-php php-mysql
This will install the following 3 packages
- php - installs PHP
- libapache2-mod-php - Used by apache to handle PHP files
- php-mysql - PHP module that allows PHP to connect to MySQL
Congratulations! we have successfully installed LAMP stack on your server.php -v