Skip to content

AndromedaIsComingg/Lamp-Stack-Implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 

Repository files navigation

Lamp-Stack-Implementation

Project 3

AWS Account & EC2 Instance

Created an AWS Account and spinned an EC2 instance named For Instance
AWS Acct

Private Key

Created and downloaded a private key named 1stkey
The .pem file was saved in the "Downloads" folder as shown below
pem file in dwnlds
From Terminal, working directory was changed to the "Downloads" folder
cd Downloads
From Terminal, permission was changed for the private key.
changing permission for private key

Connecting to the EC2 Instance

Connected to the EC2 instance by running the command ssh -i <private-key-name>.pem ubuntu@<Public-IP-address>
starting ubuntu

Installing Apache & Firewall

Updated a list of packages in package manager
Updated these packages with the command sudo apt update with the sudo giving admin privelages.
After which the Apache package was installed using the sudo apt install apache2 command
sudo apt and apache2 instl

Verifying Apache

Verified that Apache was running as a service in the os with the command sudo systemctl status apache2
apache2 verifucation

Editing Inbound Rule

Edited inbound rule such that connection through port 80 is allowed and from any ip address.editing inbound rule

Accessing Server

Accessed server locally on Ubuntu shell using the curl command as shown below
curl local host check
Tested the Apache HTTP Server with a web browser. This done by using the public ip in the address bar.
apache test web

Installing MySQL

Used apt to install this software using the command sudo apt install mysql-server
The sudo command gives admin previlages and when prompted, installation was confirmed by typing y and then pressing enter.
sudo MySQL install
After installation, logged into the Mysql Console with the command sudo mysql
MySQL Start up
Password was set for root user using the command ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PassWord.1';
user password
When done, tested to login into the MySQL console by using the command sudo mysql -p
The -p flag prompts for password after the root user password has been chnaged.
The "mysql> exit" command was used to exit the MySQL console.
login test   exit

Istalling PHP

In order to proccess codes to display dynamic content to the end users, PHP is the package to install.
In addition to PHP, we install other features like, php-mysql and libapache2-mod-php
These 3 packages were insatalled at once with the command sudo apt install php libapache2-mod-php php-mysql
PHP   co install
Afterwhich the version of PHP was confirmed using the command php -v and the verision is 8.1.2
PHP version
Changing the order of files in the default directory index such that index.php file will take precedent over index.html
This was done using the command sudo vim /etc/apache2/mods-enabled/dir.conf
Vim command
This order was edited using the insert mode in the vim editor.
pressing "i" on the keyboard takes us to the insert mode & "esc" to exit it
Changes were written and vim was exited with the command :wq!
Vim
After saving and closing the file, Apache was restarted for changes to take effect
Restart was done with the command sudo systemctl reload apache2
apache reload
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.
creating index php   dir
Inside the vim editor, the following valid PHP code was added to the newly openned blank "index.php" file
Changes were written and vim was exited with the command ":wq!"
adding php code
Removing the Created PHP file
After confirming all relevant information via the PHP file, the newly created PHP file was further removed
as it contains sensitive information about the PHP environment and the Ubuntu Server.
That was done with the command sudo rm /var/www/projectlamp/index.php
removing  php file

Creating a virtual host for the website using Apache

We will be doing this using the earlier created directory
Then we will assign ownership of the environment with the USER environment variable using the command sudo chown -R $USER:$USER /var/www/projectlamp
chown

Creating a configuration file

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:
vi for  conf code
Changes were written and vim was exited with the command ":wq!"
vi  conf vi
The ls command was used list and confirm that the new files are available in the site-available directory
ls
The a2ensite command was then used to enable the virtual host using the command sudo a2ensite projectlamp
enable virtual host   reload
The default website that comes with Apache was disabled using the code sudo a2dissite 000-default
disable defaul web
The configuration file was confirmed to not contain any syntax error using the following command sudo apache2ctl configtest
syntax errror
Apache was relaoded so that changes can take effect, this was don using the command sudo systemctl reload apache2
apache reload
To confirm that the virtual host is working as expected, an index.html file was created in the same directory
Using the echo command to display the text "Hello LAMP from hostname" using the following command
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
sudo echo php
This was finally confirmed on the web browser using the format http://<Public-IP-Address>:80 (testing usinsg the public ip address)
web test ip
Also with the format http://<Public-DNS-Name>:80 (testing using the public DNS)
web test dns

---------------------------------Alt Text---------------------------------------------

About

Project 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published