Table of Contents
How to Install LAMP on Ubuntu:
Step 1: Install Apache Web Server
- Open the terminal and enter the following commands:
sudo apt update sudo apt install apache2
- Start Apache and enable it to start on boot:
sudo systemctl start apache2 sudo systemctl enable apache2
- Check if Apache is running by entering your server’s IP address or
http://localhost
in your web browser.
Step 2: Install MySQL Database Server
- Open the terminal and install the MySQL server:
sudo apt install mysql-server
- Set a root password during the installation process.
- Start MySQL and enable it to start on boot:
sudo systemctl start mysql sudo systemctl enable mysql
Step 3: Install PHP
- Enter the following command to install PHP and establish the connection between PHP and Apache:
sudo apt install php libapache2-mod-php php-mysql
- Restart Apache to apply the changes:
sudo systemctl restart apache2
- Verify that PHP is successfully installed:
php -v
- Create a PHP info page using the following command:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/phpinfo.php
Visit
http://localhost/phpinfo.php
in your web browser to view PHP information.
Conclusion:
By following these steps, you have successfully installed a LAMP stack on Ubuntu. You can now start developing web applications and test your installation.