Hello Readers, Today I am going to show you that, How you can launch your WordPress websites over AWS and store WordPress data in the RDS database for high availability of data.
- Create a database instance using the Amazon RDS service.
- Launch an ec2 instance.
- Configure ec2 instance and install WordPress on it.
- Connect the WordPress instance with the Database instance using Public IP.
Now, Let’s start creating our website.
How to Launch RDS instance on AWS.
- Search for RDS on services Dashboard in AWS console.
- Now Click on the Create Database button.
- Now select the way, If you don’t want to do much by yourself go with the Easy Create option else go with the Standard Create option. Here I am using the standard create option.
- Next, select the Database engine you want, Here I am using MySQL.
- Now, they are asking for your Use Case, i.e How you want to use this instance, Here I am using the free tier for this blog, you can go with it according to your requirements. Along with it, it is also asking for a version of the Database Engine, Here I am going with default.
- Next, it is asking for setting up Database name, username, and password for database set the following.
- Select the instance according to your need, as I selected the Free tier before, And the free tier only supports db.t2.micro.
- Next, It is asking for selecting storage, Select storage according to your need, I am going with default for this blog.
- Here it provides the option to select availability, As I am using the free tier so it provides limited functionality. You can use this option if you are creating the setup for production or test/dev environment.
- Now, In the connectivity tab, they are asking how you want to access this database, Here I am allowing Public access, and the setting remains as default.
- Now in the last, they are asking how you want to authenticate with this database, Here I am selecting password only. You can also access this database through IAM roles by adding roles to it, You can also use Kerberos security for this, But it is only supported in the production or test/dev environment.
- Lastly, click on the Create database button to create your database instance.
Now you can see that your database instance is launched, It’s time to Launch a WordPress instance and connect it with the database.
How to Launch setup WordPress on AWS.
- First, go to the AWS dashboard and click on ec2 service.
- Now after landing on the ec2 dashboard click on the launch instance button.
- Now here they are asking you to choose an OS you want to use, Here I am going with all Amazon Linux 2.
- Next, select the Compute type as per your requirement, I am using t2.micro which is basic and free tier eligible.
- Next, Configure the instance detail
- Next, add storage according to your need.
- Next, Configure the security group, For now, I am using all traffic but it is not a good idea. Kindly choose wisely which port you want to let listen.
- Lastly, review all the details and click on the launch button. After Clicking the Launch button doesn’t forget to attach the existing ssh key or create a new ssh key in the next prompt.
Now you can see that our instance is launched and I named it wordpress.
Now Let’s start configuring WordPress on the launched instance.
- First, connect to the instance via SSH protocol.
Next, after landing at the terminal, First switch the user to root.
WordPress has a dependency on Apache webserver and MySQL, So let’s first install that in our system.
Now go to document root of httpd server, i.e “/var/www/html/” and download the following file there. https://wordpress.org/latest.tar.gz
Now untar the downloaded file.
for untar use the “tar -xf latest.tar.gz” command.
Now, Let's start installing PHP, to install PHP on amazon Linux run the following command to get the installation command for PHP.
Now, let's start the httpd service and make it permanent by enabling it.
Now, Enter the IP address of your ec2-instance followed by WordPress in your browser to open the configuration menu.
Next, It is asking for details like database name, username, password and database host.
make sure the database u specified is present in your database instance. To create a database login to your rds instance from CLI using the command.
mysql -h “endpoint” -u “username” -p “password”
Now create the database using the command
create database “database_name”;
Sometimes Wordpress is not able to create the database using WebUI, So go to your instance and create a wp-config.php file in “/var/www/html/wordpress” directory.
After creating the File and Click on “Run the installation” button, After that you will see the installation page asking for some more detail, Enter that too and Click next.
After successful installation login to your instance using username and password you’ve created.
Now you will see a dashboard which will ask you to customize your site, customize according to your need and your site will launched successfully.