Project 3
Connected to the EC2 instance by running the command ssh -i <private-key-name>.pem ubuntu@<Public-IP-address>
Verified that Apache was running as a service in the os with the command sudo systemctl status apache2
Tested the Apache HTTP Server with a web browser. This done by using the public ip in the address bar.
The sudo command gives admin previlages and when prompted, installation was confirmed by typing y and then pressing enter.
Password was set for root user using the command ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PassWord.1';
In order to proccess codes to display dynamic content to the end users, PHP is the package to install.
These 3 packages were insatalled at once with the command sudo apt install php libapache2-mod-php php-mysql
Changing the order of files in the default directory index such that index.php file will take precedent over index.html
Next, we will creating a PHP script to test that PHP is installed correctly and configured on the server.
The file name is "index.php" and the directory for this file was also created with the mkdir command.
Inside the vim editor, the following valid PHP code was added to the newly openned blank "index.php" file
After confirming all relevant information via the PHP file, the newly created PHP file was further removed
Then we will assign ownership of the environment with the USER environment variable using the command sudo chown -R $USER:$USER /var/www/projectlamp
Created and edited a new configuration with the vi editor in Apache's site-available directory using the code sudo vi /etc/apache2/sites-available/projectlamp.conf:
The ls command was used list and confirm that the new files are available in the site-available directory
The a2ensite command was then used to enable the virtual host using the command sudo a2ensite projectlamp
The configuration file was confirmed to not contain any syntax error using the following command sudo apache2ctl configtest
Apache was relaoded so that changes can take effect, this was don using the command sudo systemctl reload apache2
To confirm that the virtual host is working as expected, an index.html file was created in the same directory
sudo echo 'Hello LAMP from hostname' $(curl -s http://169.254.169.254/latest/meta-data/public-hostname) 'with public IP' $(curl -s http://169.254.169.254/latest/meta-data/public-ipv4) > /var/www/projectlamp/index.html
This was finally confirmed on the web browser using the format http://<Public-IP-Address>:80 (testing usinsg the public ip address)
---------------------------------
