# Deploy Wordpress website on AWS

Over 30% of all websites use WordPress as their content management system (CMS). It is often used to run blogs, but it can also be used to run e-commerce sites, message boards, and many other famous things. In this blog, I will show you how to set up a WordPress blog site.

Before getting ahead, let us know why we need to use RDS:

* Database maintenance for your WordPress site is critical. Your database instance holds all of your important data for your WordPress site. If the database goes down, your website may go down with it, and you could even lose your data.
    
* Database maintenance can also be difficult, and database administrators have years of specialized experience. When setting up a WordPress site, you want to stay focused on designing your page and generating your content, not worrying about database performance and backups.
    

Amazon RDS for MySQL helps with both of these problems. Amazon RDS for MySQL is a managed database offering from AWS. With Amazon RDS for MySQL, you get:

* Automated backup and recovery so that you won’t lose data in the event of an accident
    
* Regular updates and patches, keeping your database secure and performant
    
* Easy installation with smart default parameters.
    

Let’s start the project now.

We can divide this project into seven sections, for us to make it easy to understand:

Step 1: 🚀 Launch an Amazon EC2 Instance

Step 2: 🛠️ Set Up an Amazon RDS for MySQL Database

Step 3: 🔐 Create an IAM Role for EC2 with RDS Full Access

Step 4: 🔄 Connect EC2 to RDS Using MySQL Client

Step 5: 🌐 WordPress DB Creation and Apache Server Installation

Step 6: 📝 Set up the server and post your new WordPress app.

Step 7: 🌐 Explore the Newly Set Website and Clean Up.

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

so we have cover the basic configuration in the yesterday blog in day 44 here is the link , we have covered till step 4 there.... [LINK](https://gouravtoonwal.hashnode.dev/relational-database-service-in-aws)

but here are soon configurations you need to remember

* make port 3306 available in ec2 instance for mySQL
    
* give RDSfullAccess to the IAM role .
    

so here we are starting with the

**Step 5: 🌐 WordPress DB Creation and Apache Server Installation**

1. Create a database user for the WordPress application and give the user permission to access the WordPress database.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938337935/eb3b449c-db3b-441e-b469-359306c6f964.png align="center")

```bash
    CREATE DATABASE wordpress;
    CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-99';
    GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
    FLUSH PRIVILEGES;
    Exit
```

2\. To run WordPress, you need to run a web server on your EC2 instance.

To install Apache on your EC2 instance, run the following command in your terminal:

```bash
     sudo apt-get install apache2
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938538266/7f17f712-69fd-4dae-96b9-d950fb54b1b9.png align="center")

3\. To start the Apache web server, run the following command in your terminal:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938634455/89ffd040-fc9b-40e0-9d1f-c30a3435e2fd.png align="center")

```bash
    sudo systemctl restart apache2
```

4\. You can see that your Apache web server is working by browsing the public-IP of your ec2 instance...

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938716274/f8826142-4524-4d56-9a1a-f04aebfa6d80.png align="center")

# **Step 6: 📝 Set up the server and post your new WordPress app.**

Download and uncompressed the WordPress software by running the following commands in your terminal:

```bash
  wget https://wordpress.org/latest.tar.gz
  tar -xzf latest.tar.gz
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938844699/ede4cf4c-7009-427d-8e3d-97cd7919ff1c.png align="center")

Change the directory to the WordPress directory and create a copy of the default config file using the following commands

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696938900915/77c88959-1f20-472a-a08b-b843c44f6608.png align="center")

Now create a copy of the config file and edit the wp-config.php file

```bash
  sudo cp wp-config-sample.php wp-config.php
#login as root user and  first make file writable
  sudo vim wp-config.php
```

Edit the database configuration by changing the following lines:

Authentication Unique Keys and Salts:

You can generate the content of this section from this link: [**https://api.wordpress.org/secret-key/1.1/salt/**](https://api.wordpress.org/secret-key/1.1/salt/).

Replace with the existing content.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696940655501/61976744-6fd9-4a74-9362-7545cfcd0409.png align="center")

Install the application dependencies you need for WordPress. In your terminal, run the following command.

```bash
  sudo apt install php libapache2-mod-php php-mysql -y
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696940807232/a4ddbd50-f3c9-4047-b690-6314a4267eca.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696940816540/28da9413-2496-44db-9d8e-3f7005f81f49.png align="center")

Copy your WordPress application files into the /var/www/html directory used by Apache.

```bash
  sudo cp -r wordpress/* /var/www/html/
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696940875087/23486eab-44bc-4ddf-b9c2-49c85fdc70c0.png align="center")

Finally, restart the Apache web server

```bash
  sudo systemctl restart apache2
```

Browse public-ipv4address/wp-admin/ you should see the WordPress welcome page.

```bash
http://Public_IPv4/wp-admin
```

![](https://miro.medium.com/v2/resize:fit:875/1*rGjrAUEO39pXEJfC-RcRNA.png align="left")

![](https://miro.medium.com/v2/resize:fit:875/1*LW9T6Sji3Q_nfDgu-ayEag.png align="left")

And yay! You have your own WordPress website.

Now let’s step into the final section of this Project.

# **Step 7 : 🌐 Explore the Newly Set Website and Clean Up**

Once you have explored, we need to clean up the resources so that we can avoid being charged.

Delete your EC2 instance first and then the RDS.

wooo hooo , we successfully configured it...

If you've enjoyed this article and want to stay updated on the latest in the tech world, don't forget to connect with me on [**GOURAV TOONWAL**](https://www.linkedin.com/in/gourav-toonwal/) . Let's keep the conversation going and explore the exciting world of technology together. Follow for more insights, discussions, and tech updates.

thanks for your support........

spreading knowledge in the community ...
