How to install LAMP Stack on Ubuntu
In this tutorial, we will explain How to install LAMP Stack on Ubuntu
LAMP is an archetypal model of web service stacks, named as an acronym of the names of its original four open-source components: the Linux operating system, the Apache HTTP Server, the MySQL relational database management system, and the PHP programming language.
You will need:
- A VPS running Ubuntu
- And to update your system:
sudo apt update
Step 1 – Install Apache
The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows.
You can install Apache by following this command:
sudo apt install apache2
Note: When asks for prompt type Y and hit Enter.
After, you need to start and enable the apache:
sudo systemctl start apache2
Allow incoming HTTP and HTTPS traffic:
sudo ufw allow in “Apache Full”
Step 2 – Install MySQL
Now you need to install MySQL. We will need MySQL to store information on the website.
To install it, run this command:
sudo apt install mysql-server
After, you need to start and enable it:
systemctl start mysql
systemctl enable mysql
Now its time to secure the installation.
You will be asked for a password, so just hit Enter.
After, you will be asked a series of questions.
- Set root password? [Y/n]
Type y if you want to set.
- Remove anonymous users? [Y/n]
Type y if you want to remove.
- Disallow root login remotely? [Y/n]
Type y if you want to disallow.
- Remove test database and access to it? [Y/n]
Type y to remove.
- Reload privilege tables now? [Y/n]
Type y to reload privileges.
Step 3 – Install PHP
PHP is a popular general-purpose scripting language that is especially suited. To install PHP and MySQL extension you need to run the following command:
sudo apt install php libapache2-mod-php php-mysql
Restart web service to get effects:
sudo systemctl restart apache2
Step 4 – Test PHP
You need to test PHP if is working. You can do it by running the following command:
echo “<?php phpinfo();” > /var/www/html/phpinfo.php
Now go to your browser and open this URL http://youripaddress/phpinfo.php to see PHP configuration information.
You have successfully installed LAMP Stack in CentOS.