- Update the package index and upgrade the existing packages on the server:
sudo apt update
sudo apt upgrade
- Install Apache web server:
sudo apt install apache2
- Allow Apache through the firewall:
sudo ufw allow in "Apache"
- Check if Apache is running by visiting your server’s IP address in a web browser:
http://your_server_ip_address
- Install MySQL:
sudo apt install mysql-server
- Run a secure installation of MySQL and set the root password:
sudo mysql_secure_installation
- Install PHP:
sudo apt install php libapache2-mod-php php-mysql
- Create a test PHP file:
sudo nano /var/www/html/info.php
Add the following code and save the file:
<?php
phpinfo();
?> - Restart Apache:
sudo systemctl restart apache2
- Visit the test PHP file in a web browser by entering the following URL:
http://your_server_ip_address/info.php
- Delete the test PHP file after verifying the installation:
sudo rm /var/www/html/info.php