Table of contents
π Introduction:
In this blog, we will deploying a WordPress website on AWS. WordPress is a popular content management system (CMS) used by millions of websites worldwide. By leveraging AWS services like Amazon EC2 and Amazon RDS, we can set up a highly scalable and reliable WordPress environment.
Over 30% of all websites on the internet use WordPress as their content management system (CMS). It is most often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other popular things. This guide will show you how to set up a WordPress blog site.
π―Task: 1
As WordPress requires a MySQL database to store its data, create an RDS.
- Sign in to the AWS Management Console and open the Amazon RDS console
- Go to the RDS dashboard and then choose Create database
- On the Create database page, choose Standard create and then choose MySQL as the database engine.
- Under the Templates section, choose the Free tier
- Under the Settings section, enter a name for your database instance
- Under the Credentials Settings section, enter a username and a password for your database
- Under the Instance configuration section, choose Burstable classes (includes t classes) and then choose db.t3.micro as the instance type
- Under the Storage section, choose General Purpose (SSD) as the storage type and enter
20
as the allocated storage.
- Under the Connectivity section, Select Don't Connect to an EC2 compute resource and select the Default VPC.
- Under the VPC security group (firewall) Section, Select Choose existing, and on the security group select default.
- Under the Database authentication section, choose Password authentication as the authentication method & Click on Create Database
- Under the Additional Configuration section, give Initial database name
- Database created
An Amazon EC2 instance to install and host the WordPress application.
Go to the Amazon EC2 console
Click Launch Instance, Choose a Linux AMI
- Choose an instance type, such as t2.micro and Choose Key-pair(login)
- Choose a VPC and subnet
- Launch the instance
Allow EC2 instance to access our WordPress database
- Go to the Amazon RDS databases page in the AWS console. Choose the MySQL database you created in the earlier
- Scroll to the Connectivity & security tab in the display and choose the security group listed in VPC security groups
- Select the Inbound Rules tab, then choose the Edit inbound rules button to change the rules for your security group.
Change the Type property to MYSQL/Aurora For Source, enter wordpress. The console will show the available security groups that are configured. Choose the wordpress security group that you used for your EC2 instance.
Click on Save rules
An Amazon RDS for MySQL database to store your WordPress data
- Install a MySQL client in your terminal to access the database
sudo apt install mysql-client -y
mysql --version
- Connect to the RDS instance using the MySQL client and the endpoint address, username, and password
mysql -h <endpoint address> -P <port.no> -u <username> -p
mysql -h wordpress.cj0gy0agmk2z.ap-southeast-1.rds.amazonaws.com -P 3306 -u admin -p
- Create a database user for your WordPress application, and then grant access to the WordPress database to the user.
CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'pass';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
Exit
- On your EC2 instance install Apache
sudo apt-get install apache2 -y
- To check the Apache service status
sudo systemctl restart apache2
sudo systemctl status apache2
- Verify that your Apache web server
Set up the server and post your new WordPress app.
- Download the latest version of WordPress and extract the archive
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
- Change the directory to the WordPress directory and create a copy of the default config file
cd wordpress
cp wp-config-sample.php wp-config.php
- Then, open the wp-config.php file in vim editor and modify the following lines in the database configuration
DB_NAME: your RDS database name
DB_USER: The name of the user you created in the database in the previous steps
DB_PASSWORD: The password for the user you created in the previous steps
DB_HOST: The hostname of the database means your database endpoint
The Authentication Unique Keys and Salts configuration area is the second one that needs to be set up.
You can substitute the following text for everything in that section:
Go to this link to generate values for this configuration section. You can replace the entire content in that section with the content from the link.
- Installing WordPress application dependencies
sudo apt install php libapache2-mod-php php-mysql -y
- copy your WordPress application files into the /var/www/html directory used by Apache.
sudo cp -r wordpress/* /var/www/html/
- Restart the Apache web server
sudo systemctl restart apache2
sudo systemctl status apache2
- To access the WordPress admin dashboard, open a web browser and enter the following URL:
http://ec2-public-ip/wp-admin/
π Conclusion :
In this blog, we successfully deployed a WordPress website on AWS, leveraging services like Amazon EC2 and Amazon RDS., in the next blog we will cover AWS Topics.
Thank you for reading!
Contact me on Linkedin
Check out my GitHub for more resources π