Here is a step-by-step guide to installing Apache, PHP, and MySQL on an AWS EC2 instance running Ubuntu:

- Launch an EC2 instance running Ubuntu. You can choose the version of Ubuntu you want to use based on your requirements.
- Connect to your instance using SSH. You can use any SSH client to connect to your instance. If you are using a Windows machine, you can use PuTTY.
- Update the packages using the following command:
codesudo apt-get update
- Install Apache using the following command:
sudo apt-get install apache2
- Once Apache is installed, start the service using the following command:
sudo service apache2 start
- Check that Apache is running by opening a web browser and navigating to your instance’s public IP address. You should see the Apache default page.
- Install PHP using the following command:
sudo apt-get install php libapache2-mod-php php-mysql
- Install MySQL using the following command:
sudo apt-get install mysql-server
- During the installation process, you will be prompted to set a root password for MySQL. Make sure to set a strong password.
- Once MySQL is installed, secure it by running the following command:
sudo mysql_secure_installation
- Follow the prompts to set up the security options for MySQL.
- Once PHP and MySQL are installed, restart Apache to load the PHP module:
sudo service apache2 restart
- Test the installation by creating a PHP file in the Apache document root directory:
sudo nano /var/www/html/info.php
- Add the following code to the file:
<?php
phpinfo();
?>
- Save the file and close the editor.
- Open a web browser and navigate to your instance’s public IP address followed by
/info.php
. You should see a page displaying information about your PHP installation.
Congratulations! You have successfully installed Apache, PHP, and MySQL on an AWS EC2 instance running Ubuntu.