0% found this document useful (0 votes)
123 views9 pages

Host A WordPress Website Using LAMP Stack Using EC2 and AWS RDS

The document describes how to host multiple WordPress sites on a single EC2 instance using LAMP stack. It includes creating an RDS database instance and EC2 instance in the same availability zone, installing WordPress on the EC2 instance, and configuring the sites to use the RDS database. It also provides instructions for hosting additional WordPress sites on subdomains using the same EC2 and RDS instances and securing each site with SSL certificates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
123 views9 pages

Host A WordPress Website Using LAMP Stack Using EC2 and AWS RDS

The document describes how to host multiple WordPress sites on a single EC2 instance using LAMP stack. It includes creating an RDS database instance and EC2 instance in the same availability zone, installing WordPress on the EC2 instance, and configuring the sites to use the RDS database. It also provides instructions for hosting additional WordPress sites on subdomains using the same EC2 and RDS instances and securing each site with SSL certificates.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

# Task 9

1. Host a WordPress website using LAMP stack using EC2 and AWS RDS

2. Another task (How to host multiple site on single server)--> host 2 more WordPress sites inside the
same server using the same EC2 instance and same RDS instance --> and also install SSL certificates for
each of the subdomains.
1. Host a WordPress website using LAMP stack using EC2 and
AWS RDS.
- Create RDS and EC2 instance in same availability zone with same security group. In
creation RDS, put master user name and password for connection of RDS in connection.
- In security group make sure ssh, http, https and Mysql/Aurora ports are enabled.
- After created the RDS connect with ssh though the IP of instance. Better use elastic ip
for ec2 insatnce.

- Connect instance, install mysql and connect RDS database. To connect instance with
following IP

ssh -i "key.pem" [email protected]

To install lamp server and mysql


sudo yum update -y sudo
yum install -y mysql

To connect RDS with following endpoint


mysql –h wp.cttijxskmgj0.us-east-1.rds.amazonaws.com –P 3306 –u admin –p
with admin as a master user and enter the password and create database if not create in
RDS and create user for the database.

CREATE DATABASE wordpress-db;


CREATE USER 'username' IDENTIFIED BY 'wordpress-pass';
GRANT ALL PRIVILEGES ON wordpress-db.* TO username;
FLUSH
PRIVILEGES;
Exit

- Install apache server sudo yum install -y httpd


sudo service httpd start

After installing the apache we can see apache test page in curl of IP.

- Configure wordpress Download and unzip wordpress

wget
checkhttps://wordpress.org/latest.tar.gz
if file is exit or not in the instance is following files are exist or
tar
not. -xzf
latest.tar.gz
$
ls
latest.tar.gz
wordpress

copy and configure following file


cd wordpress
cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Edit the above section with same as database created in RDS and put endpoint of RDS in
DB_HOST.
The second configuration section you need to configure is the Authentication Unique
Keys and Salts. It looks as follows in the configuration file:
From here>>
https://api.wordpress.org/secret-
key/1.1/salt/

- Install PHP in lamp server.


sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

- Then, copy your WordPress application files into the /var/www/html directory used by
Apache. sudo cp -r wordpress/* /var/www/html/
Finally, restart the Apache web server to pick up the changes.
If we have created the folder inside the html and we want to host from the folder
sudo mkdir /var/www/html/wordpress sudo cp -r wordpress/*
/var/www/html/wordpress and we have to configure the conf.d of apche server.
sudo nano /etc/httpd/conf.d/vhost.conf

put following in virtual host with your proper domain name.

<VirtualHost *:80>
ServerAdmin root@localhost
ServerName iamsks.tk
ServerAlias www.iamsks.tk
DocumentRoot /var/www/html/wordpress/
</VirtualHost>

And restart
apache
sudo service httpd restart

(Note: we can curl our site through IP address for but for domain, we have to register
domain name as well as in route53 we have create hosted zone and record with contain of
IP address of ec2 instance.)
Till now we have hosted site in http port now we have run the site on secure shell (SSL)

Install SSL
To Install
epel
sudo amazon-linux-extras install epel
-

to install certbotin
apache
sudo yum install certbot-apache

Generate and issue certificate for the domain name


sudo certbot --apache –d iamsks.tk
and restart apache
sudo service httpd restart
now run your site in secure shell and configure the wordpress site. And that may seems
as:

2. Another task (How to host multiple site on single server)--> host 2 more
WordPress sites inside the same server using the same EC2 instance and same
RDS instance --> and also install SSL certificates for each of the subdomains
- For this we have to create go in route53 and host subdomain first and copy the name
server of the subdomain in main domain in a record as follows:

- subdomain

- main domain

Now we have to follow the same procedure as above.


- Connect rds and create new database from subdomain
CREATE DATABASE wordpress-db1;
CREATE USER 'username1' IDENTIFIED BY 'wordpress-pass1';
GRANT ALL PRIVILEGES ON wordpress-db1.* TO
username1;
FLUSH
PRIVILEGES;
Exit
- Make a directory for site inside /var/www/html/
sudo mkdir /var/www/html/wordpress1 sudo cp -r
wordpress/* /var/www/html/wordpress1 and we
have to configure the conf.d of apche server. sudo
nano /etc/httpd/conf.d/vhost1.conf

put following in virtual host with your proper subdomain name.


<VirtualHost *:80>
ServerAdmin root@localhost
ServerName suppot.iamsks.tk
ServerAlias www.support.iamsks.tk
DocumentRoot /var/www/html/wordpress1/
</VirtualHost>

And restart
apache
sudo service httpd restart

Till now we have hosted site in http port now we have run the site on secure shell (SSL)

Install SSL
To Install
epel
sudo amazon-linux-extras install epel
-

to install certbotin
apache
sudo yum install certbot-apache

Generate and issue certificate for the domain name


sudo certbot --apache –d support.iamsks.tk

and restart
apache
sudo service httpd restart

now run your site in secure shell and configure the wordpress site. And that may
seems
as:

You might also like