Cld4_TK

profilehybridtek
AW4_Tut.docx

Activity Tutorial

Note: Variations in images may occur as the AWS website changes.

In this tutorial, you will first set up a new EC2 instance using your AWS Academy account. Then you will install PHP, MySQL, and WordPress to complete a working website.

To start, log into your AWS Academy account here.

After logging into your account, navigate to the ‘Learner Lab’ under modules in your AWS Academy Learner Lab – Foundation Services course.

Select ‘Start Lab’. The lab with launch. This may take a couple of minutes. Once complete, select ‘AWS’ in the top left. This will have a green mark next to it when ready.

This brings you to the AWS Management Console. From the management console, you will be able to launch a virtual machine by clicking All Services and selecting EC2.

On the left side Menu select AMIs under Images.

Next you will need to change the search bar parameters. Click on Owned by me to the left of the search bar and then select Public Images.

Click in the search bar and choose "Owner", then choose "Amazon images"

Click in the search bar again and choose "Source", then type in "amazon/Cloud9Ubuntu"

For this exercise, any of the AMIs in the result set should be launchable. Choose the checkbox next to one and select Launch. • Note: Click on AMI Name to see the latest

Next is step 2, Choose an Instance Type.

· Select General purpose, the t2.micro option, which is labeled “Free tier eligible.”

· At the bottom of the page, click Review and Launch.

Complete all the steps, proceeding to step 7. After you select your operating system, you can review the build using the default setup. When ready, click Review and Launch in the bottom right of the page.

To connect to your new EC2 server, you must provide a key pair or create a new one. To create a new key pair, choose Create a new key pair, then enter your name followed by .pem (for instance, “JohnSmith.pem”. Next, make sure to click Download Key Pair and store it in an easily remembered location. Click Launch Instances when you’re ready to continue.

To view your instances from the EC2 Dashboard, click Instances on the menu on the left. After your instance shows green and is running (this may take a few minutes), you will select the security groups link found on the bottom right side of your main EC2 page.

See the example of the location highlighted below. (Alternatively, you can use the left menu and click Security groups.)

Once you have clicked on the default security group, you will be brought to a screen that lists all available security groups. Find the security group that your EC2 is using and right-click on it. You will be changing settings to allow incoming traffic from http and https from anywhere.

Once both are set as shown above, return to the EC2 dashboard using the left menu. For this next section, you will need to make use of an SSH client. This tutorial will be using Termius . You may also consider using PuTTY . Once you have an SSH client installed on your PC, continue.

To make the connection to the EC2 server, you will need some information. You can find your public DNS IP from the main EC2 Dashboard near the bottom right of the page. It will be in the following format: ec2-3-95-218-56.compute-1.amazonaws.com. This will be the address you are connecting to. You will be using the default port of 22, ssh protocol, and the default instance username is ubuntu. Last, you will need to use the private key you downloaded as a password. Additional guidance: Termius SSH Client Installation , Termius Key Pair Instructions , PuTTy SSH Client

Installation , PuTTy Key Pair Instructions

Once you have all the information added, connect to the instance. It should look like the following screenshot:

Next, you will need to be the root user to install and set up software. To start, enter the following:

sudo su apt-get update && apt-get upgrade

You will be entering “Yes” for all questions during the update. Once you are finished, you will install PHP 7.

1

1

1

PHP 7

Enter the following:

apt-get install php libapache2-mod-php php-mysql

After successful installation, run the following command:

php -v

Your output should look like the following screenshot.

After you have verified that your response is PHP 7.2, enter the following to download some extensions that PHP will need:

apt-get install php-pear php-curl php-dev php-gd php-mbstring php-zip php-xml php.xmlrpc php.soap

You will be entering “Yes” for all questions during the installation.

MySQL

To store the information for the website, you will be using MySQL. Continue by entering the following:

apt install mysql-server mysql_secure_installation

Enter "y" for password.

Enter "0" (zero) for security.

Enter new password: SNHU

Enter "y" for rest of setup

Once the installation is complete, you can enter into the MySQL command prompt. Enter the following:

mysql

Your command prompt should now look like: "mysql>".

Next create a WordPress user for the database on localhost:

CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'SNHU_2020'; GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;

Next create the database that WordPress will use to store data. We will call it wordpressdb:

CREATE DATABASE wordpressdb;

The expected result is "Query OK."

Type "exit" to leave the mysql console. Next, you will need to restart the instance to make sure all changes have been updated and are running as expected. Enter the following:

service apache2 restart

WordPress

First you need to change into the web directory on the server by entering the following:

cd /var/www/html

Next you need to retrieve the latest build of WordPress. Do this by using the wget command:

wget http://wordpress.org/latest.tar.gz

Then unpack the tar file by entering:

tar -xzvf latest.tar.gz

This will create a WordPress directory inside the html folder. You can view it by entering the dir command.

dir

Then, you need to make sure that ownership of the WordPress directory is correct and accessible to the installation:

chown -R www-data:www-data /var/www/html/wordpress find /var/www/html/wordpress/ -type d -exec chmod 750 {} \; find /var/www/html/wordpress/ -type f -exec chmod 640 {} \;

Next enter into the new directory:

cd wordpress

Install

Install

1

1

1

Create your wp-config.php file from the sample file that comes with the install:

mv wp-config-sample.php wp-config.php

This file then needs to be edited to include the database connection. Use vi wp-config.php or nano wp-config.php to open the file editor.

In vi editor, type “i” to edit the file.

Next you need to edit the database configuration parameters to match your previous MySQL setup. Make changes in this file to match the following:

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */ define( 'DB_NAME', 'wordpressdb' );

/** MySQL database username */

define( 'DB_USER', 'wordpress' );

/** MySQL database password */ define( 'DB_PASSWORD', 'SNHU_2020' );

/** MySQL hostname */

define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' );

Also, add the following line after the previous one:

define('FS_METHOD', 'direct');

Once you are done editing the file, save and exit the editor. For nano editor, Ctrl+x, then type “y” to save and exit. For vi editor, press Esc, then “:wq” to save and exit.

Set Up WordPress

Your site is now all set to be viewed from your EC2 dashboard. Find your public domain name system (DNS). Enter it in a browser followed by

/wordpress since our setup is within the wordpress directory within our html folder. For example: http:// ec2-3-95-218-56.compute1.amazonaws.com/wordpress for the EC2 shown below. Make sure to change the URL to match your public DNS from your dashboard.

Next you should be redirected to the WordPress install page.

Fill in the following information:

Site title: SNHU IT-423

Username: siteadmin

Password: generated for you

Your Email: [email protected]

Make sure to write down your password before continuing. This is used to access the admin panel for your site.

Click Install WordPress to continue. Next, you will log in with the credentials you just created. You now have a fully set up WordPress installed on an EC2 server using PHP and MySQL. To view your new site, insert the URL of your instance in a new browser tab (e.g., http://whateveritis.compute-1.amazonaws.com/wordpress/).

1

1

1