# Day 45: Deploy Wordpress website on AWS (Jan 10, 2024)

**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 famous things. This guide will show you how to set up a WordPress blog site.**

## Task-01

**As WordPress requires a MySQL database to store its data, create an RDS as you did on Day 44**

* **Create an Amazon RDS for MySQL Database**
    
    1. **Go to the Amazon RDS console.**
        
    2. **Click on "Create database" and select "MySQL" as the database engine.**
        
    3. **Configure the database details, including the DB instance identifier, username, password, database name, and other settings as per your requirements.**
        
        ![](https://lh4.googleusercontent.com/ZCxfEEhObYMnE55M2eiPnfI8DKcf-8X-2j8Mqy8ZwWhwQ1k-CtQv7eq5baVjCBUyZWOWDBd65m14lacGTAxOYWQEIvf_OJ7j2pjKdLkPj79V3M_W1j2JqBxrc7Qjnh9pGsxTeI-PQb4TsLDkkZy8xcU align="left")
        
        1. **Configure the VPC, subnet, and security group settings for the RDS instance.**
            

![](https://lh6.googleusercontent.com/Db3loo--8fhQNfVNhNiQgY5lHB6rAdjWRG2qphHoryYQtyWWeKYQ-6Kpd6YQDAu_5ml2a4bG2HQxYeIrhfyLMbb6HqHUafzrvkBNK3Z8JocX5HgPPrFzbYbDwQjjlScXLZOjo9ATFkmpVsu-rB5yJZI align="left")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689473987886/03e5b4a3-4450-489c-bafc-bd272ed762b0.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

1. **Finally, create the RDS database.**
    

![](https://lh4.googleusercontent.com/WPwD27XT00Dq5z1rvd7sy9tHk84apSjSFdQtt83c8Atx6p0xko3xw7Axc0S4UNSSmOnpH-HR4ZzHMq_4YLhIz1H6-RD9FuhbajaRpSfXMYdfUrSbX5UoHgqhDpIIy7WkBamLhFAwWvtrV_sd3FDqPfE align="left")

**📢 To configure this WordPress site, you will create the following resources in AWS:**

* **An Amazon EC2 instance to install and host the WordPress application.**
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689477450141/b3f8a794-97ec-4f0c-b7ce-5f84a7ccfa57.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")
    
    **Run the following command in your terminal to install a MySQL client to interact with the database.**
    

```plaintext
     sudo apt install mysql-client -y
```

**Run the following command in your terminal to connect to your MySQL database. Replace “&lt;user&gt;” and “&lt;password&gt;” with the master username and password you configured when creating your Amazon RDS database. -h is the host which is the RDS database endpoint.**

```plaintext
    mysql -h <RDS hostname> -u <master username> -p
```

**Finally, create a database user for your WordPress application and give the user permission to access the WordPress database.**

**Run the following commands in your terminal:**

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476481135/761ce6c0-d2f5-405c-bbaf-0bbf2ee65d98.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**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:**

```plaintext
 sudo apt-get install apache2 -y
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476555956/459fb41d-49b8-43ca-97a1-1d2b027e6c99.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**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/v1689476586415/40a690a6-1918-4143-81f8-f821972152c9.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**First, download and uncompress the software by running the following commands in your terminal:**

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476665424/bd8b1106-f5cf-4ef5-a64f-e9db10941134.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**You will see a tar file and a directory called WordPress with uncompressed contents using the ls command.**

```plaintext
cp wp-config-sample.php wp-config.php
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476698632/3f9cd201-97dd-414e-b062-db648372d764.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**Open the wp-config.php file**

* **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**
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476858141/27a55aa3-11ee-4c3c-9900-485d7747d6fd.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**To configure the Authentication Unique Keys and Salts section in the WordPress** `wp-config.php` **file, you can replace the entire content in that section with the following content:**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689476887041/3d9da889-25c0-498b-beab-587f958bdc67.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**First, install the application dependencies you need for WordPress.**

**In your terminal, run the following command.**

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689477260729/2b2a393a-2bf9-4dec-82d0-6f479c2dc66d.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

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

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1689477142455/01386cf7-beab-484c-a7a3-c9c7ba795b93.png?auto=compress,format&format=webp&auto=compress,format&format=webp align="left")

**To restart the Apache web server**

```plaintext
 systemctl restart apache2
```

**To access the WordPress admin dashboard, open a web browser and enter the following URL:** [`http://ec2-public-ip/wp-admin/`](https://hemanshubtc.hashnode.dev/day-45-deploy-wordpress-website-on-aws#heading-task-01)**, where** `ec2-public-ip` **should be replaced with the public IP address or domain name of your Amazon EC2 instance.**

* **An Amazon RDS for MySQL database to store your WordPress data.**
    
* **Set up the server and post your new WordPress app.**
