Illustrated Steps to create greggroeten.net with AWS Screenshots of each step Table of Contents 1. CREATE VPC 10.10.0/16.... 3 2. CREATE 1 PUBLIC SUBNET IN DEFAULT AZ, EX BELOW... 4 3. CREATE IGW, ATTACH TO VPC... 5 4. CREATE PRIVATE ROUTE TABLE, RENAME DEFAULT RT TO PUBLIC... 6 5. ASSOCIATE PRIVATE SUBNETS TO PRIVATE RT... 7 6. ADD IGW TO PUBLIC RT, IF DESTINATION IS 0.0.0.0/0 RT WILL ROUTE TO TARGET IGW... 8 7. CREATE EC2 INSTANCE, ROETEN-VPC, PUBLIC SUBNET 1A, ENABLE PUBLIC IP (RESTART WILL LOOSE IP, ASSIGNED NEW IP) AUTO CREATE ETH0 NETWORK INTERFACE... 9 8. SECURITY GROUP... 12 9. LAUNCH, CREATE NEW KEY PAIR, DOWNLOAD KEY PAIR VIRGINIAKEY.PEM... 13 10. SETUP ROUTE53 AND DOMAIN NAME... 16 11. CREATE SIMPLE ROUTING POLICY WITH TYPE A = ALIAS RECORD SET GREGGROETEN.NET AND EC2 PUBLIC IP 34.200.246.139... 17 12. UPDATE NS RECORDS WITH GODADDY ACCOUNT... 18 1
13. WEB SERVER ON AMAZON LINUX... 19 14. INSTALL MYSQL... 25 15. STEP 7: INSTALL WORDPRESS... 28 16. CONNECT TO GREGGROETEN.NET USING ROUTE53 TO EC2 HOSTING WORDPRESS APPLICATION INSTEAD OF PUBLIC IP... 34 2
1. Create VPC 10.10.0/16. AMI Linux 2, ************* Linux 2 Reqs mariadb and other differences between regular Linux 3
2. Create 1 Public subnet in default AZ, ex below 4
3. Create IGW, Attach to VPC VPC dashboard Internet Gateway, Create Internet Gateway 5
4. Create Private Route Table, rename default RT to Public 6
5. Associate Private Subnets to Private RT 7
6. Add IGW to Public RT, if Destination is 0.0.0.0/0 RT will route to Target IGW VPC setup completed 8
7. Create EC2 instance, Roeten-VPC, Public Subnet 1a, Enable Public IP (restart will loose IP, assigned new IP) auto create eth0 Network Interface Disclosure, tried Linux Bitnami Wordpress three times could not configure nor trougbleshoot connection with http or SSH, reverted to basic Linux AMI and adding Wordpress manually. Which I have done in the past successfully. Following is an example of this setup. Add userdata Bootstrap script, #!/bin/bash yum install httpd -y service httpd start chkconfig httpd on yum install wget -y yum install php php-mysql mysql -y 9
10
Add Tags Name WebServer 11
8. Security Group SSH TCP 22 0.0.0.0/0 default HTTP TCP 80 0.0.0.0/0 add, test OK, production delete later 12
9. Launch, Create new key Pair, Download Key Pair VirginiaKey.pem 13
View Instances, Pending, Initializing 14
Running, Initializing 15
10. Setup Route53 and Domain Name Public IP: 34.200.246.139 or Elastic IP RDS endpoint groetendb.crrhgplksbww.us-east-1.rds.amazonaws.com Cannot access RDS instance groetendb.crrhgplksbww.us-east-1.rds.amazonaws.com on 3306 yet Setup Route53 and Domain Name Route53 greggroeten.net 16
11. Create Simple Routing policy with type A = Alias Record Set greggroeten.net and EC2 public IP 34.200.246.139 Create Simple Routing policy with type A = Alias Record Set www.greggroeten.net and EC2 public IP 34.200.246.139 17
12. Update NS records with godaddy account Go to godaddy account DNS Management Nameservers Change Custom Copy Route53 DNS names to GoDaddy ns-943.awsdns-53.net. ns-328.awsdns-41.com. ns-1112.awsdns-11.org. ns-1830.awsdns-36.co.uk. Now greggroeten.net domain from GoDaddy is mapped Route52 and Route52 is mapped to EC2 instance 18
13. Web Server on Amazon Linux Ex MobaXterm, SSH to EC2 server, Elastic IP, Advanced SSH settings use private key load.pem, user = ec2-user, MoabXterm user private key PEM username ec2-user Authenticating with public key "Imported-Openssh-Key: C:\Users\groeten\Desktop\Roeten-EC2-Key-Pair.pem" MobaXterm 10.9 (SSH client, X-server and networking tools) 19
SSH session to ec2-user@xxxxxxxxxxx SSH compression : SSH-browser : X11-forwarding : (disabled or not supported by server) DISPLAY : 192.168.0.100:0.0 For more info, ctrl+click on help or visit our website _ ) _ ( / Amazon Linux AMI \ https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/ [ec2-user@ip-10-0-1-197 ~]$ ls -al total 24 drwx------ 3 ec2-user ec2-user 4096 Nov 22 22:49. drwxr-xr-x 3 root root 4096 Nov 22 22:49.. -rw-r--r-- 1 ec2-user ec2-user 18 Aug 30 2017.bash_logout -rw-r--r-- 1 ec2-user ec2-user 193 Aug 30 2017.bash_profile -rw-r--r-- 1 ec2-user ec2-user 124 Aug 30 2017.bashrc drwx------ 2 ec2-user ec2-user 4096 Nov 22 22:49.ssh 20
[ec2-user@ip-10-0-1-197 ~]$ yum install httpd Loaded plugins: priorities, update-motd, upgrade-helper You need to be root to perform this command. [ec2-user@ip-10-0-1-197 ~]$ sudo su [root@ip-10-0-1-197 ec2-user]# yum install httpd Loaded plugins: priorities, update-motd, upgrade-helper Complete! [root@ip-10-0-1-197 ec2-user]# service httpd start Starting httpd: [ OK ] [root@ip-10-0-1-197 ec2-user]# yum install php php-mysql Loaded plugins: priorities, update-motd, upgrade-helper Complete! [root@ip-10-0-1-197 ec2-user]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] 21
[root@ip-10-0-1-197 ec2-user]# cd /var/www/html [root@ip-10-0-1-197 html]# ls -al total 8 drwxr-xr-x 2 root root 4096 Nov 1 2017. drwxr-xr-x 6 root root 4096 Nov 22 23:11.. [root@ip-10-0-1-197 html]# pwd /var/www/html [root@ip-10-0-1-197 html]# vi test.php [root@ip-10-0-1-197 html]# ls test.php Test your web server. In a web browser, type the public DNS address (or the public IP address) of your instance 22
EC2 web address Enter IP to verify Apache loaded EC2 web address/test.php Verify php created displays basic php page 23
24
14. Install MySQL [root@ip-10-0-1-197 html]# yum install mysql-server Installed: mysql-server.noarch 0:5.5-1.6.amzn1 Complete! [root@ip-10-0-1-197 mysql55]# mysqladmin -u root -h ip-18.235.18.205 password 'gr-password' mysqladmin: connect to server at 'ip-18.235.18.205' failed error: 'Unknown MySQL server host 'ip-18.235.18.205' (2)' Check that mysqld is running on ip-18.235.18.205 and that the port is 3306. You can check this by doing 'telnet ip-18.235.18.205 3306' [root@ip-10-0-1-197 html]# service mysqld start Initializing MySQL database: Installing MySQL system tables... PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER! To do so, start the server, then issue the following commands: /usr/libexec/mysql55/mysqladmin -u root password 'new-password' /usr/libexec/mysql55/mysqladmin -u root -h ip-10-0-1-197 password 'new-password' Alternatively you can run: /usr/libexec/mysql55/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. 25
See the manual for more instructions. You can start the MySQL daemon with: cd /usr ; /usr/libexec/mysql55/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/ [ OK ] Starting mysqld: [ OK ] [root@ip-10-0-1-197 html]# mysqladmin -uroot create blog [root@ip-10-0-1-197 mysql55]# pwd /usr/libexec/mysql55 [root@ip-10-0-1-197 mysql55]# [root@ip-10-0-1-197 mysql55]# mysqladmin -u root password 'gr-password' mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: NO)' mysqladmin -uroot -p proc Enter password: will not display password when enter +----+------+-----------+----+---------+------+-------+------------------+ Id User Host db Command Time State Info +----+------+-----------+----+---------+------+-------+------------------+ 26
13 root localhost Query 0 show processlist +----+------+-----------+----+---------+------+-------+------------------+ [root@ip-10-0-1-197 mysql55]# cd /var/www/html 27
15. Step 7: Install WordPress To install WordPress, type: cd /var/www/html wget http://wordpress.org/latest.tar.gz tar -xzvf latest.tar.gzcd This will uncompress WordPress in its own wordpress directory. I like having WordPress in a separate directory, but would rather rename it to blog : mv wordpress blog Create the WordPress wp-config.php file: cd blog mv wp-config-sample.php wp-config.php vi wp-config.php 1. Type i to start insert mode. 2. Modify the database connection parameters as follows: define( DB_NAME, blog ); define( DB_USER, root ); define( DB_PASSWORD, YOUR_PASSWORD ); define( DB_HOST, localhost ); 3. Type :wq to write the file and quit vi Install wordpress Goal is to access greggroeten.net using Route53 through EC2 to Wordpress application sudo su cd /var/www/html wget https://wordpress.org/latest.tar.gz tar -xvzf latest.tar.gz cd wordpress/ required package mv * /var/www/html move to www/html so can pick up data cd /etc/httpd/conf vi httpd.conf Change Allow overide parm to All chown -R apache:apache /var/www 28
http://ec2-18-235-18-205.compute-1.amazonaws.com/blog/wp-admin/install.php username password same as in wp-config.php file 29
30
31
32
Access http://ec2-18-235-18-205.compute-1.amazonaws.com/blog/ 33
16. connect to greggroeten.net using Route53 to EC2 hosting Wordpress application instead of public IP Route53, Create Hosted Zone, Enter domain name in the Domain Name field 34
Create Record Set Add A Record 35
36
paste your public IP (EIP) into the Value field, then click the Create button at the bottom of the page 37
Add CNAME Record, type www in the Name field, and select CNAME as the record type 38
Edit Domain Name Servers Copy AWS NS nameservers values to GoDaddy Test Settings www.greggroeten.net -> apache default page www.greggroeten.net/blog -> default wordpress page 39
40
here. Once everything is configured and mapped correctly, access the General Settings in the WordPress management console and make sure the WordPress Address and Site Address are specified correctly using your domain name as in the screenshot below. www.greggroeten.com http://www.greggroeten.com/wp-login.php?redirect_to=http%3a%2f%2fwww.greggroeten.com%2fwpadmin%2fpost.php%3fpost%3d469%26action%3delementor&reauth=1 www.greggroeten.net http://ec2-18-235-18-205.compute-1.amazonaws.com/blog/wp-login.php?loggedout=true 41
42
Can now access greggroeten.net using Route53 through EC2 to Wordpress application Use Elementor in Wordpress to create website 43
44