Host A WordPress Website Using LAMP Stack Using EC2 and AWS RDS
Host A WordPress Website Using LAMP Stack Using EC2 and AWS RDS
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
After installing the apache we can see apache test page in curl of IP.
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
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/
- 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
<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
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
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
and restart
apache
sudo service httpd restart
now run your site in secure shell and configure the wordpress site. And that may
seems
as: