December 1, 2023

A step-by-step guide to installing Apache, PHP, and MySQL on an AWS server?

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

  1. Launch an EC2 instance running Ubuntu. You can choose the version of Ubuntu you want to use based on your requirements.
  2. 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.
  3. Update the packages using the following command:
 codesudo apt-get update
  1. Install Apache using the following command:
sudo apt-get install apache2
  1. Once Apache is installed, start the service using the following command:
sudo service apache2 start
  1. 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.
  2. Install PHP using the following command:
sudo apt-get install php libapache2-mod-php php-mysql
  1. Install MySQL using the following command:
sudo apt-get install mysql-server
  1. During the installation process, you will be prompted to set a root password for MySQL. Make sure to set a strong password.
  2. Once MySQL is installed, secure it by running the following command:
sudo mysql_secure_installation
  1. Follow the prompts to set up the security options for MySQL.
  2. Once PHP and MySQL are installed, restart Apache to load the PHP module:
sudo service apache2 restart
  1. Test the installation by creating a PHP file in the Apache document root directory:
sudo nano /var/www/html/info.php
  1. Add the following code to the file:
<?php
phpinfo();
?>
  1. Save the file and close the editor.
  2. 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.