Launching WordPress with AWS RDS
In this article we are going to launch WordPress on an RHEL AWS instance and use AWS RDS with MySQL as its database. I tried to explains the steps as much as I could considering that you’re very new to this.
What is WordPress?
In technical terms, WordPress is free and open-source web-creation platform written in PHP that can work with MySQL and MariaDB databases. Simply put, WordPress lets you create your own website or blog. WordPress has become the most popular web publishing platform since its release in 2003. It powers more than 39% of the web which includes even some of the popular websites like Etsy Journal, TechCrunch, Microsoft News, TED Blog etc.
It is so easy to use you feel like working on an app like MS Word where you can edit the interface of you site without even knowing a single line of code. Also, as it is an open-source software it has a lot of contributors and support developers throughout the globe. Also, it comes with flexible features like exporting your data away from WordPress or importing it from some other platform.
AWS RDS is a relational database service by Amazon which lets you create a cloud-based database. RDS provides scalable databases are easy to set-up and provide good performances. Using a cloud-based database is very important in these days because it will provide a server that will be 24*7 available and you can scale it accordingly which won’t be possible in a local database server.
Launching AWS RDS database
Launching an RDS database is very simple. Click on Create Database and you’ll get to enter the configurations of you server.
Choose standard create and then choose MySQL.
Choose the latest version that appears on version and go for free tier.
Give a name to your DB instance ( this name has nothing to do with later configurations), and in credentials give a username which will be an admin user for your Database server. Create a password on your own for ease.
Choose burstable classes.
Give allocated storage( can’t give less than 20 GiB ).
Choose VPC and subnets and give a public access to your server for sure or you won’t get a public IP address. In additional configuration below you can change the port for your server or let it be default.
Choose a security group of create your own at that instance. Let the inbound rule be as it just edit the IP address range that can access the server and put the IP of instance on which you’ll be launching WordPress.
For now going for password authentication to make it simple.
In additional service you can enter the database name or you can create one by going into your server from any other ec2-instance. You’ll need this database created for WordPress. For now, we’re going to do it from other instance.
After creating it go to database in AWS and note the end-point provided. This end-point is used to access your database.
First we need to have an OS on whose webserver we’ll launch our WordPress application. So, we’re using free tier t2.micro instance launched with redhat 8 image.
After that download httpd sofware on it :
yum install httpd -y
Download WordPress and un-tar it:
curl https://wordpress.org/latest.tar.gz --output wordpress.tar.gz
tar xvf wordpress.tar.gz
Move the files to /var/www/html and give permission to and give the ownership of the web root apache to let WordPress make changes on its own.
cp -rv wordpress/ /var/www/html
chown -R apache:apache /var/www/html/wordpress
WordPress is written on PHP and needs PHP software installed along with the plugins. The initial plugins required to run WordPress are:
yum install php-mysqlnd php-json -y
Later you can install php-fpm for more functionalities.
SELinux is one more thing that can get in your way. So, either make it permissive by:
or change the SELinux context or label to allow httpd service to control processess in wordpress file using :
chcon -t httpd_sys_rw_content_t /var/www/html/wordpress -R
The WordPress application is all good to go. Before that we need to make a database in the server. So, from the same ec2 instance we’ll install MySQL first.
yum install mysql -y
Get inside your DB server :
mysql -h <end-point> -u <user-name> -p
mysql -h db-instance.cjp7z7d5hynl.ap-south-1.rds.amazonaws.com -u rahul -p
in my case, and enter password. Now, simply create a database:
>create database wordpress_db;
Query OK, 1 row affected (0.01 sec)
Now, you’re all done with the configurations. Open the WordPress application using localhost:<port> or localhost:3306 in my case.
A page will open up and choose the language or continue to next page to get something like this:
And enter your details.
Database name : the one you created inside the database or one named while making RDS.
Username : One you gave as master username in beginning of RDS creation.
Password : The one you gave in RDS creation in database authentication.
Dataset Host : Your database’s end-point.
No need to change the last option.
After this it will proceed to install and ask for credential authentications for logging into WordPress (not any of the previous usernames and passwords).
And its done, you’re WordPress application has been configured!