0% found this document useful (0 votes)
26 views102 pages

Wordpress Project Document

The document outlines various methods for deploying a WordPress application using AWS services, including RDS for MySQL, Docker, Jenkins, userdata scripts, and Terraform. Each method details the necessary steps for setting up the AWS infrastructure, configuring security groups, launching EC2 instances, and installing WordPress. It also highlights the importance of proper configuration and permissions for successful deployment.
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)
26 views102 pages

Wordpress Project Document

The document outlines various methods for deploying a WordPress application using AWS services, including RDS for MySQL, Docker, Jenkins, userdata scripts, and Terraform. Each method details the necessary steps for setting up the AWS infrastructure, configuring security groups, launching EC2 instances, and installing WordPress. It also highlights the importance of proper configuration and permissions for successful deployment.
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/ 102

Deployment of WordPress application in

different methods

Submitted by,
Ch. Harshath,
AWS DevOps internship batch.
Deploy WordPress web application by using AWS
RDS(MYSQL) service.

Prepare AWS Infrastructure


Create an RDS MySQL Database
1. Go to the AWS Management Console.
2. Navigate to RDS → Databases → Click Create
database.

3. Choose Standard create.


4. Engine options: Select MySQL.
5. Database version: Choose a preferred MySQL version
(e.g., 8.0.x).
6. Deployment options: Select Multi-AZ (optional for
production) or Single-AZ for simplicity. Choose as free-
tier
7. Settings

DB Instance Identifier: wordpress-db.

Master Username: e.g., admin.

Password: Set a strong password.

8. Configure instance size and storage based on your


requirements.
9. Networking: Attach the RDS to the appropriate VPC and configure subnet groups.

10. Security group: Create or select an appropriate SG to allow MySQL traffic (default
port: 3306).
11. Click Create database and wait for the instance to be available.
Configure RDS Security Group

1. Navigate to EC2 → Security Groups.


2. Edit the security group attached to your RDS instance

 Add an inbound rule to allow traffic on port 3306 from the IP range of your
WordPress server.

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.


Select an AMI (e.g., Amazon Linux 2 or Ubuntu).

Choose an instance type (e.g., t2.micro for testing or a larger instance for production).
Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Launch the instance and connect using an SSH client.

Install webserver in instance server

sudo yum update -y

sudo yum install -y httpd php php-mysqlnd

sudo systemctl start httpd

sudo systemctl enable httpd


Download and Configure WordPress

sudo wget https://wordpress.org/latest.tar.gz

sudo tar -xzf latest.tar.gz

sudo mv wordpress/* .

sudo rm -rf wordpress latest.tar.gz

Set permissions

sudo chown -R apache:apache /var/www/html

sudo chmod -R 755 /var/www/html

Configure WordPress to Use RDS

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

sudo nano wp-config.php

update the database configuration in the file


define('DB_NAME', 'your-database-name');

define('DB_USER', 'your-username');

define('DB_PASSWORD', 'your-password');

define('DB_HOST', 'your-rds-endpoint');

define('DB_CHARSET', 'utf8');

define('DB_COLLATE', '');

Create a database in server

Enter in the mysql and create database

export MYSQL_HOST=<rds endpoint>

mysql -h <rds endpoint > -u username -p password

Now create a database user for your wordpress application and give it permission to access
the “wordpress” database. By using this commands as
CREATE USER ‘wordpress’ IDENTIFIED BY ’wordpress-pass’;
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
EXIT
Complete WordPress Installation
Open a browser and navigate to your EC2 instance's public IP.

Follow the on-screen WordPress setup:


 Enter site title, admin username, password, and email.
You can see the WordPress application
2.Deploy WordPress web application by using docker
compose.
First login to the AWS account with credentials.
Now give the name for EC2 instance.

Select your AMI linux or ununtu 22.04 ltd free tier 22,80

Launch instance with any one of the terminal.


Install git, docker and setup docker environment. And provide
permissions for admint socket file.
Now install the docker compose

Now give permissions to add limited linux user account to docker group by
using a command as “<sudo usermod -aG username(ec2-user)> or <sudo
usermod -a -G username(ec2-user)> another command is <sudo chmod 666
/var/run/docker.sock>
create a file with the name of docker-compose.yml.

After creation of docker-compose file run the command to create


container

“Docker-compose up -d”
Now access the ip address in the browser we can see the wordpress
application
3. Deploy WordPress web application by using git and
jenkins?
Prepare AWS Infrastructure
Create an RDS MySQL Database
12. Go to the AWS Management Console.
13. Navigate to RDS → Databases → Click Create
database.

14. Choose Standard create.


15. Engine options: Select MySQL.
16. Database version: Choose a preferred MySQL
version (e.g., 8.0.x).
17. Deployment options: Select Multi-AZ (optional for
production) or Single-AZ for simplicity. Choose as free-
tier
18. Settings

DB Instance Identifier: wordpress-db.

Master Username: e.g., admin.

Password: Set a strong password.

19. Configure instance size and storage based on your


requirements.
20. Networking: Attach the RDS to the appropriate VPC and configure subnet groups.

21. Security group: Create or select an appropriate SG to allow MySQL traffic (default
port: 3306).
22. Click Create database and wait for the instance to be available.
Configure RDS Security Group

4. Navigate to EC2 → Security Groups.


5. Edit the security group attached to your RDS instance

 Add an inbound rule to allow traffic on port 3306 from the IP range of your
WordPress server.

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.


Select an AMI (e.g., Amazon Linux 2 or Ubuntu).

Choose an instance type (e.g., t2.micro for testing or a larger instance for production).
Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Launch the instance and connect using an SSH client.

Now install the Jenkins setup

To install Jenkins install Jenkins dependency

Yum install java-17 -y

Go to Jenkins.io and click on download and click on redhat and


paste the commands in server

sudo wget -O /etc/yum.repos.d/jenkins.repo


https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-


2023.key

Next install Jenkins

yum install Jenkins -y

systemctl start Jenkins

systemctl enable Jenkins


Now the access the ip address in bowser with port number <ip
address>:8080

Now copy the path and get the password from the server and paste it
Install Plugins

Go to manage Jenkins and select the pulgins

Install the git, docker and docker compose plugin select and install it

Now go to Jenkins job and configure it

Give the github docker-compose url link in git


In Jenkins server setup the mysql database and httpd we done in first method
After completion of these steps browse the ip address we can get the wordpress
application
4. Deploy WordPress web application by using userdata
of EC2 instance?
Create an Amazon EC2 Instance
Log in to the AWS Management Console.

Go to the EC2 Dashboard.

Select an Amazon Machine Image (AMI):

 Choose Amazon Linux 2 or Ubuntu Server.


Select an Instance Type:

 Choose an instance type like t2.micro (free tier eligible).

Choose security group and click on launch instance.


After launching the instance

Give the userdata in the userdata file

#!/bin/bash

# Update packages

yum update -y

# Install Apache web server

yum install -y httpd

systemctl start httpd

systemctl enable httpd

# Install PHP and necessary extensions

amazon-linux-extras enable php7.4


yum install -y php php-mysqlnd

# Install MariaDB client (for connecting to RDS or local DB)

yum install -y mariadb

# Download and install WordPress

cd /var/www/html

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

tar -xzf latest.tar.gz

mv wordpress/* .

rm -rf wordpress latest.tar.gz

# Set permissions

chown -R apache:apache /var/www/html

chmod -R 755 /var/www/html

# Restart Apache to apply changes

systemctl restart httpd

# Print completion message

echo "WordPress installation completed!" >


/var/www/html/index.html
After executing the userdata file and create the database we created
in before methods do it in server
After creating database now copy the ip address and
browse it then we can see the wordpress application.
5.Deploy WordPress web application by using git and
jenkins execute shell (bash script)?
Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).

Choose an instance type (e.g., t2.micro for testing or a larger instance for production).
Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Launch the instance and connect using an SSH client.

Now install the Jenkins setup

To install Jenkins install Jenkins dependency


Yum install java-17 -y

Go to Jenkins.io and click on download and click on redhat and


paste the commands in server

sudo wget -O /etc/yum.repos.d/jenkins.repo


https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-


2023.key

Next install Jenkins

yum install Jenkins -y

systemctl start Jenkins

systemctl enable Jenkins

Now the access the ip address in bowser with port number <ip
address>:8080

Now copy the path and get the password from the server and paste it
Infrastructure:
 A server with Apache or Nginx installed.
 WordPress-compatible environment (PHP, MySQL, etc.).

Tools:

 Jenkins server configured.


 Git installed on both the Jenkins server and the target server.
 SSH access set up between Jenkins and the target server.
Permissions:
 Jenkins must have access to clone the repository.
 Sudo permissions for file transfers and web server restarts.

Repository:
 WordPress source code hosted in a Git repository.
After save and build the job when it is success

Now run the ip address in browser then we can get the wordpress application.
6. Deploy WordPress web application by using git and jenkins execute shell (bash script)
create jenkins pipeline add build periodically and poll scm to initial job of pipeline and
check the changes happened or not which are made in github repo?

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).

Choose an instance type (e.g., t2.micro for testing or a larger instance for production).
Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Launch the instance and connect using an SSH client.

Now install the Jenkins setup

To install Jenkins install Jenkins dependency


Yum install java-17 -y

Go to Jenkins.io and click on download and click on redhat and


paste the commands in server

sudo wget -O /etc/yum.repos.d/jenkins.repo


https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-


2023.key

Next install Jenkins

yum install Jenkins -y

systemctl start Jenkins

systemctl enable Jenkins

Now the access the ip address in bowser with port number <ip
address>:8080

Now copy the path and get the password from the server and paste it
Now create the job1 and configure it
Now create the job 2 and configure
Now install the build pipeline follow the process to install it

Now go to dashboard and click on the manage Jenkins

Select the pulgins


Now search the build pipeline and select it

Now click on plus button on top of jobs and give name and select build pipeline
Now configure it

After run the pipeline


Now run the IP address in the browser we can see the wordpress
application
7.Deploy WordPress web application by using terraform
(create Ec2 instance along with userdata .sh file)?

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).


Choose an instance type (e.g., t2.micro for testing or a larger instance for production).

Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Launch the instance and connect using an SSH client.
Now install the terraform in the instance

sudo yum-config-manager --add-repo


https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

sudo yum -y install terraform

check now the terraform is installed or not

terraform -version

After now run the userdata file

Userdata

#!/bin/bash

# Update system packages

sudo yum update -y

# Install Apache and start the service

sudo yum install -y httpd

sudo systemctl start httpd

sudo systemctl enable httpd

# Install MySQL client

sudo yum install -y mysql

# Install PHP and required extensions

sudo amazon-linux-extras enable php7.2

sudo yum install -y php php-mysqlnd

# Download and configure WordPress

cd /var/www/html
wget https://wordpress.org/latest.zip

unzip latest.zip

mv wordpress/* .

rm -rf wordpress latest.zip

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

# Configure wp-config.php

sed -i "s/database_name_here/wordpress/" wp-config.php

sed -i "s/username_here/harshath/" wp-config.php

sed -i "s/password_here/harshath4891/" wp-config.php

sed -i "s/localhost/wordpress.ct2qacwoeede.us-east-1.rds.amazonaws.com

# Restart Apache to apply changes

sudo systemctl restart httpd

Now run the userdata file with this command – “sh userdata.sh”

Now create the file with main.tf

provider "aws" {

region = "us-east-1" # Replace with your desired region, such as "us-west-2" or "eu-west-1"

resource "aws_instance" "wordpress" {

ami = "ami-0166fe664262f664c" # Replace with the appropriate AMI for your region

instance_type = "t2.micro" # Choose an instance type


key_name = "aws2" # Replace with your existing key pair name

user_data = file("userdata.sh")

tags = {

Name = "WordPress-Instance"

security_groups = [aws_security_group.wordpress_sg.name]

resource "aws_security_group" "wordpress_sg" {

name = "wordpress-sg2"

description = "Allow HTTP, HTTPS, and SSH traffic"

ingress {

from_port = 22

to_port = 22

protocol = "tcp"

cidr_blocks = ["0.0.0.0/0"]

ingress {

from_port = 80

to_port = 80
protocol = "tcp"

cidr_blocks = ["0.0.0.0/0"]

ingress {

from_port = 443

to_port = 443

protocol = "tcp"

cidr_blocks = ["0.0.0.0/0"]

egress {

from_port = 0

to_port =0

protocol = "-1"

cidr_blocks = ["0.0.0.0/0"]

Now run the terraform commands to create the new instance

Terraform init

Terraform validate

Terraform plan
Terraform apply - -auto-approve

Now run the ip address in the browser then we can get the wordpress application
8. Deploy WordPress web application by using git (clone terraform script which helps to
deploy WordPress web application), jenkins (in execute shell install terraform, init, fmt,
validate and apply with automatic command as terraform apply --auto-approve) and
terraform.

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).


Choose an instance type (e.g., t2.micro for testing or a larger instance for production).

Configure instance details:


 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).

Launch the instance and connect using an SSH client.


Now install the Jenkins in the server with java dependency

Yum install java-17 -y

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

yum install Jenkins -y

systemctl start Jenkins

systemctl enable Jenkins

Now the access the ip address in bowser with port number <ip
address>:8080

Now copy the path and get the password from the server and paste it
Now create a job and configure the git and run the commands in the builds steps.
Now install the terraform in the instance

sudo yum-config-manager --add-repo


https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo

sudo yum -y install terraform

check now the terraform is installed or not

terraform -version

push the before project into github and paste the url in this Jenkins file
Now build the Jenkins job and run the ip address in the browser we can get the wordpress
application
9. Deploy WordPress web application by using git (clone terraform script which helps to
deploy WordPress web application), jenkins (in execute shell install terraform, init, fmt,
validate and apply with automatic command as terraform apply --auto-approve) and terraform
and create jenkins pipeline and add build periodically and poll scm to initial job of pipeline
and check the changes happened or not which are made in github repo.

Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).


Choose an instance type (e.g., t2.micro for testing or a larger instance for production).

Configure instance details:


 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).

Launch the instance and connect using an SSH client.


Now install the Jenkins in the server with java dependency

Yum install java-17 -y

sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key

yum install Jenkins -y

systemctl start Jenkins

systemctl enable Jenkins

Now the access the ip address in bowser with port number <ip
address>:8080

Now copy the path and get the password from the server and paste it
Now create the first job 1 and configure

Select the git and paste the github url


Now click the build steps and write builds commands you can see the below images

Now got the post build actions and select build other project and select job 2 after creating
job2
Now create the job2 and configure the build periodically and poll scm and click on save
Now install the build pipeline follow the process to install it

Now go to dashboard and click on the manage Jenkins

Select the pulgins


Now search the build pipeline and select it

Now click on plus button on top of jobs and give name and select build pipeline
Now configure it

After run the pipeline


Now access the ip address in the browser we can get the wordpress application
10. Deploy WordPress web application by using k8’s
(Declarative manifest method) with the help of docker hub
images?
Launch an EC2 Instance for WordPress

Go to EC2 → Instances → Click Launch Instances.

Select an AMI (e.g., Amazon Linux 2 or Ubuntu).


Choose an instance type (e.g., t2.micro for testing or a larger instance for production).

Configure instance details:

 Attach it to the same VPC and subnet as the RDS instance.

Add storage as needed (e.g., 20 GB for WordPress).


Allocate the storage volume 25 and Launch the instance and connect using an SSH client.

Now install the KOPS & kubectl in the instance server

Step 1: Launch Instance with t2.micro and take 20GB SSD

Step 2: Install AWS CLI

- curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

- unzip awscliv2.zip

- sudo ./aws/install

- vim .bashrc

- export PATH=$PATH:/usr/local/bin

- source .bashrc

- aws --version
Step 3: Install KOPS and kubectl

- curl -LO "https://dl.k8s.io/release/$(curl -L -s


https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

- wget https://github.com/kubernetes/kops/releases/download/v1.24.1/kops-linux-amd64

- chmod +x kops-linux-amd64 kubectl

- mv kubectl /usr/local/bin/kubectl

- mv kops-linux-amd64 /usr/local/bin/kops

- kubectl version & kops version

Step 4: Create an IAM User with Administration Access and configure it with CLI in any
region

Step 5: Create Infrastructure

- Create Bucket: aws s3api create-bucket --bucket harshath.k8s.local --region us-east-1

- Enable Versioning for that bucket

- Export Cluster Data to Bucket: export KOPS_STATE_STORE=s3://suneel.k8s.local

- Generate a Key: ssh-keygen

- To Create Cluster: kops create cluster --name harshath.k8s.local --zones us-east-1a --


master-size t2.medium --node-size t2.micro

Update the Cluster: kops update cluster --name harshath.k8s.local --yes –admin
Now create the pod.yml file in the server

---

apiVersion: v1

kind: Pod

metadata:

name: pod-1

labels:

app: wordpress

spec:

containers:

- Name: cont -1

Image: harshath14/wordpress

Ports:

- containersPort: 80
Now run the pod.yml file with this command

Kubectl apply -f pod pod-1

Now create the service file

---

apiVersion: v1

kind: service

metadata:

name: harshath

spec:

type: Nodeport

selector:

app: wordpress

ports:

- port :80

Now create the file with this command

Kubectl apply -f service harshath


Now the run the command to see the pod

Kubectl get svc

You can see the created pods and copy the port number and copy the node instance ip address
and paste in the browser and we can get the wordpress application

<node ip address>:pod port number

You might also like