Assistanz
Assistanz

Host WordPress website in the E2 Instance with Remote RDS (Mysql)

In this blog, I will show you the steps to host a WordPress website in the EC2 Instance with Remote RDS (Mysql)

 

Launch the RDS :

 

Step 1: Click the create database option in the RDS console. Select the Standard to create and MySQL as our DB engine.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 2: Select the appropriate version of MySQL as per your needs and select

the free tier in templates

 

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql) 

Step 3: Provide a name for your RDS and create a master username and password. We have selected the admin as our master username

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 4: db.t2.micro is selected by default. Because we have selected the free tier in the templates section.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 5: We have selected the gp2 as our storage type and 20 GiB for storage size.

 

Disabled the storage autoscaling. You can enable the storage auto-scaling as per your needs.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 6: Select the same VPC as our instance is configured. We have selected the default VPC. Our instance launched in a default vpc.

 

Disable the public access for our RDS.

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

 

Step 7: Select the existing Security group or create a new one as per your needs.

 

We have selected the Security group and Availability zone which is used by our EC2 Instance.

 

Our RDS will be launched in the below-mentioned AZ.

 

We can modify the Database port in the additional configuration. In this, we have selected the default DB port.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 8: We have selected password authentication as our authentication type.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 9: For the initial database, we have provided the name wordpress and selected the default parameter group. You can change as per your needs.

 

Disabled the automatic backups in this architecture. It is recommended to enable it in the production environment.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 10: We have deselected the logs in this. You can select the appropriate logs as per your needs.

 

We have disabled the minor version upgrade in this. You can enable it and change the maintenance window as per your needs.

 

It is recommended to enable deletion protection in the production environment.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 11: Finally create your database and it will be available in your rds console.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Install the LAMP stack and wordpress on the Linux server.

 

Step 1: Install the Apache webserver

 

Command: # apt install apache2 -y

 

Type the IP address in the browser and we will get the below the page in our browser.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 2: Install the PHP.

 

Command : # apt install php php-mysql -y

 

To verify the php is installed, create a file info.php in /var/www/html/ directory.

 

Add the below line in that PHP file.

 

<?php phpinfo(); ?>

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Access the info.php file using an IP address like this http://ip-address/info.php

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 3: Install the MySQL client in the Linux server.

 

Command : # apt install mysql-client -y

 

Go to the AWS RDS console and copy the RDS endpoint.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 4: Connect the rds using the below command.

 

Command : # mysql -h wp-rds.xxxxxxxxxx.AWS-REGION.rds.amazonaws.com -u admin -p

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Show the databases. During RDS creation we have specified to create the initial database. We can see that here.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 5: We will create and configure users for our wordpress.

 

Command : > CREATE USER ‘wordpress’ IDENTIFIED BY ‘wordpress-123’;

 

> GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
> FLUSH PRIVILEGES;

> exit

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 6: Download the wordpress.

 

Command : # cd /tmp && wget https://wordpress.org/latest.tar.gz

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 7: Uncompress the wordpress tar file.

 

Command : # tar -xvf latest.tar.gz

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 8: Copy the wordpress directory into the /var/www/html directory.

 

Command : # cp -R wordpress /var/www/html/

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 9: Change the ownership of the /var/www/html/wordpress directory and modify the file permission.

 

Command : # chown -R www-data:www-data /var/www/html/wordpress/
# chmod -R 755 /var/www/html/wordpress/

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 10: Go to the wordpress directory and copy the wp-config-sample.php.

 

Change the ownership of the wp-config.php file.

 

Command : # cd /var/www/html/wordpress

# cp wp-config-sample.php wp-config.php

# chown www-data:www-data wp-config.php

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 11: Edit the wp-config.php file and add below lines in wp-config.php file.

define( ‘DB_NAME’, ‘database_name_here’ );

/** MySQL database username */
define( ‘DB_USER’, ‘username_here’ );

/** MySQL database password */
define( ‘DB_PASSWORD’, ‘password_here’ );

/** MySQL hostname */
define( ‘DB_HOST’, ‘localhost’ );

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 12: Add the secure values from the wordpress secret key generator

 

Command : # curl -s https://api.wordpress.org/secret-key/1.1/salt/

 

You will get the values like this

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Copy this value and add it in the wp-config.php file

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 13: Now we will configure the apache to load wordpress as the main site.

 

Go to the /etc/apache2/sites-available directory and copy the 000-default.conf file.

 

Command : # cp 000-default.conf wordpress.conf

 

Edit the wordpress.conf file and add the below line

 

DocumentRoot /var/www/html/wordpress

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 14: Check the apache syntax configuration.

 

Command : # apachectl configtest

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 15:  Enable the WordPress.conf and disable the 000-default.conf and reload the apache service.

 

Command : # a2ensite wordpress.conf
# a2dissite 000-default.conf

# service apache2 reload

 

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

Step 16: Go to the /var/www/html/wordpress directory and add below line in the .htaccess file.

 

DirectoryIndex index.php

 

Step 17: Now access the Linux server IP address in the browser to see the wordpress site.

 

Select your preferred language.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 18: Provide the site title, Admin user name, password, E-Mail address, and click the install wordpress button below.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 19: Finally, we have installed our wordpress site in our Linux Server.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Step 20: Now we can log in as wp-admin to our wordpress site.

 

Host WordPress Website In The EC2 Instance With Remote RDS (Mysql)

 

Thus hosting the WordPress website in the EC2 Instance with Remote RDS (Mysql) has been done.

Most Popular:

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about new products, updates.

DirectAdmin Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk
$ 99 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • NDA & SLA
  • SLA Review Meetings
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation
  •  

Platinum Support

24/7 Proactive Support
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Support

$ 30 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response Time
  • 4 Hours Resolution time for the Possible Issues
  • Security and Performance Optimization
  • React to Customers queries
  • Simple SignUp Process
  • Instant Account Activation
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support

Cpanel Server Management Plans

Premium Support

24/7 End User Support from your Helpdesk

$ 99 Monthly / Server
  • 24/7 End User White Label Support
  • Unlimited Number of Tickets
  • Chat Support for Admin
  • Separate Account Manager
  • Guaranteed SLA
  • Weekly Status Reports
  • FREE Consultancy Services
  • Simple SignUp Process
  • Instant Account Activation

Platinum Support

24/7 Proactive Server Management
$ 49 Monthly / Server
  • Unlimited Support Plan
  • 24/7 Emergency Phone
  • Chat Support for Admin
  • Separate Account Manager
  • Advance Proactive Monitoring
  • Guaranteed SLA
  • SLA Review Meetings
  • 3rd Party Application Support
  • FREE Consultancy Services
  • Server Migration Support
  • Weekly Status Report
  • No End User Support
Popular

Unlimited Support

24/7 Server Management

$ 29 Monthly / Server
  • Unlimited Admin Tasks
  • 24/7 Support
  • Basic Monitoring
  • 30 Minutes Response time
  • 4 hours Response time for possible issues
  • Security and Performance Optimization
  • React to Customers queries
  • No Third party application support
  • No Migration and End User Support