Introduction
In this blog, we'll walk you through the process of creating and deploying a WordPress website on the powerful AWS platform using traditional methods. This hands-on tutorial will empower you to set up your virtual computer on Amazon EC2, where you'll install the Apache web server and MySQL database management system. Following that, we'll guide you through the process of downloading and installing WordPress, a widely acclaimed content management system written in PHP
Step 1: Create an MYSQL RDS DataBase
Log in to your AWS Management Console.
Navigate to the RDS service.
Click on "Create database".
Select "MySQL" as the database engine.
Choose "Free Tier" in the "Templates" section.
Configure other settings:
Set the DB instance identifier (e.g.,
wordpress-db
).Set master username and password.
Adjust other configurations as needed.
Under Connectivity:
Make sure to select a VPC with public access or appropriate network configuration.
Make sure to select a security group allowing incoming connections on port 3306 (default MySQL port).
Additional configuration:
You can add an initial database if needed.
Click "Create database".
Note: Wait for the RDS instance to be created. This may take a few minutes.
To get more detailed instructions on how to create an RDS instance, you can visit the following link:
Step 2: Launch an EC2 Instance for WordPress and make a connection with the database
In this step, we simply make the ec2 instance and make the connection with the MySQL database that we created above. Also, we make the database for our website.
Log in to your AWS Management Console.
Navigate to the EC2 service.
Click on "Launch Instance" to start the instance creation process.
Choose an Amazon Machine Image (AMI):
Use an appropriate AMI, such as Amazon Linux 2 or an Amazon Linux AMI.
Select an instance type:
Choose a suitable instance type. For testing purposes, a t2.micro (part of the free tier) is sufficient.
Configure the instance details:
Configure network settings, subnets, and security groups. Make sure that the security group allows incoming connections on port 80 (HTTP) and port 22 (SSH).
Add storage:
- Adjust the storage size if needed.
Review and Launch:
Choose an existing key pair or create a new one for SSH access.
Finally, click "Launch Instances"
Connect to RDS MySQL Server:
Navigate to the
Action > Networking > Connect to RDS database
Choose the database role for this we choose
Instance
Choose the RDS database that we created just above
Then simply choose
connect
Connecting from EC2 to RDS:
SSH into your EC2 instance.
Install the MySQL client if it's not already installed:
sudo apt update sudo apt install mysql-client
Connect to your RDS instance using the MySQL client. Replace
<RDS-endpoint>
,<port>
,<username>
, and<password>
with your actual RDS endpoint, port, username, and password:mysql -h <RDS-endpoint> -P <port> -u <username> -p
Creating the database for the website
Simple paste these command one by one
-- Create a database named 'wordpress' CREATE DATABASE wordpress; -- Create a user named 'wordpress' with the password 'wordpress-pass' CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-pass'; -- Grant all privileges on the 'wordpress' database to the 'wordpress' user GRANT ALL PRIVILEGES ON wordpress.* TO wordpress; -- Refresh privileges FLUSH PRIVILEGES; -- Exit the MySQL shell Exit
To get more detailed instructions on how to create an RDS instance, you can visit the following link:
Step 3:Install Apache Web-server on EC2
Connect to Your Ubuntu EC2 Instance:
ssh -i <your-key.pem> ubuntu@<your-ec2-instance-ip>
Update Package Information:
sudo apt update
Install Apache:
sudo apt install apache2 -y
Start Apache:
sudo systemctl start apache2
Enable Automatic Start:
sudo systemctl enable apache2
Conformation:
paste the IP address of your instance in your web-browser
Allow Traffic on Port 80:
Configure the security group for your EC2 instance to allow incoming traffic on port 80.
Check Apache Status:
sudo systemctl status apache2
Step 4: Download and Install WordPress
Download the latest version of WordPress:
Use
wget
to download the latest version of WordPress:wget https://wordpress.org/latest.tar.gz
Extract the downloaded file:
Use
tar
to extract the downloaded archive:tar -xzf latest.tar.gz
Navigate to WordPress Directory:
Change the current directory to the
wordpress
folder:cd wordpress
Copy Configuration File:
Create a copy of the sample configuration file:
cp wp-config-sample.php wp-config.php
Edit Database Configuration:
Open
wp-config.php
in a text editor and modify the following lines with your RDS instance information:vim wp-config.php
define( 'DB_NAME', 'database_name_here' ); define( 'DB_USER', 'username_here' ); define( 'DB_PASSWORD', 'password_here' ); define( 'DB_HOST', 'localhost' );
Replace
'database_name_here'
,'username_here'
, and'password_here'
with your actual RDS database name, username, and password.
Generate Authentication Keys:
Visit the WordPress secret key generator to generate unique authentication keys and paste them into the
wp-config.php
file.
Step 5: Deploying WordPress website
Install Required Dependencies:
- Update package information and install PHP 8.1:
sudo apt update
sudo apt install php8.1
Copy WordPress Directory:
- Navigate to the directory where you downloaded WordPress:
# Example: cd /path/to/wordpress
sudo cp -r wordpress/* /var/www/html/
Restart Apache Web Server:
- Restart the Apache web server to apply the changes:
sudo systemctl restart apache2
View Deployed WordPress Website:
- Access the deployed WordPress website using the IP address of the EC2 instance in your web browser.
Complete WordPress Installation:
- Fill out the required details on the WordPress installation page and click on "Install WordPress".
Log In to WordPress admin Dashboard:
Use the created user credentials to log in to the WordPress admin dashboard.
Conclusion:
With these steps, you've successfully deployed a WordPress website on your EC2 instance, and you can now start customizing and managing your website content.
Thank you for diving into this blog with me! I trust you found the information both helpful and enlightening. To stay updated on the latest in DevOps ๐, make sure to follow me. Remember, staying informed means staying ahead in the dynamic world of DevOps!
Feel free to connect with me on:
For more updates and engaging discussions on DevOps, let's connect! ๐ #DevOpsCommunity
Happy Learning! Keep pushing those boundaries! ๐