Installing the LAMP Stack on Ubuntu: A Step-by-Step Guide
The LAMP stack is a collection of open-source software that’s commonly used for web development. It includes the Linux operating system, the Apache web server, the MySQL database server, and the PHP programming language.
In this article, we’ll discuss how to install the LAMP stack on Ubuntu, one of the most popular Linux distributions.
Step 1: Install Apache
The first step in installing the LAMP stack is to install the Apache web server. To do this, open a terminal window and enter the following command:
sudo apt-get install apache2
This will download and install Apache on your Ubuntu system. After the installation is complete, you can check that Apache is running by opening a web browser and entering the following URL:
http://localhost/
If Apache is running correctly, you should see a default Apache web page.
Step 2: Install MySQL
The second step in installing the LAMP stack is to install the MySQL database server. To do this, open a terminal window and enter the following command:
sudo apt-get install mysql-server
This will download and install MySQL on your Ubuntu system. During the installation process, you will be prompted to create a password for the MySQL root user. Make sure to remember this password, as you’ll need it later.
After the installation is complete, you can check that MySQL is running by entering the following command:
sudo systemctl status mysql
If MySQL is running correctly, you should see a message indicating that the service is active.
Step 3: Install PHP
The third and final step in installing the LAMP stack is to install the PHP programming language. To do this, open a terminal window and enter the following command:
sudo apt-get install php libapache2-mod-php php-mysql
This will download and install PHP on your Ubuntu system, as well as the Apache module for PHP and the MySQL module for PHP.
After the installation is complete, you can test that PHP is running by creating a PHP file in the Apache web root directory. To do this, enter the following command:
sudo nano /var/www/html/info.php
This will open a new file in the Nano text editor. Enter the following PHP code into the file:
<?php
phpinfo();
?>
Save the file and exit the text editor. You can now test that PHP is running correctly by entering the following URL into a web browser:
http://localhost/info.php
If PHP is running correctly, you should see a PHP info page that displays information about your PHP installation.
Conclusion
In this article, we discussed how to install the LAMP stack on Ubuntu, one of the most popular Linux distributions. By following these steps, you can install Apache, MySQL, and PHP on your Ubuntu system and begin developing web applications using the LAMP stack.