Deploying Wordpress website on AWS

This is Day 45 of #90daysofdevops challenge

Deploying Wordpress website on AWS

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

What is WordPress?

WordPress is a free and open-source content management system (CMS) written in PHP and paired with a MySQL or MariaDB database. WordPress provides an easy way for anyone to create and manage a website without much technical knowledge through its intuitive admin interface and ecosystem of plugins and themes.

Task: Deploying WordPress on AWS with RDS and EC2

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

  • An Amazon EC2 instance to install and host the WordPress application.

  • After creating the EC2 instance, Configure security group rules to allow inbound traffic on the appropriate port for the type of database you are using (e.g. port 3306 for MySQL).

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

  • Now, Login to AWS EC2 instance and install MySQL-client in the server using the below command:
sudo apt update
sudo apt install apache2 php libapache2-mod-php php-mysql -y
  • After installing MySQL-Client, Login to the database server and connect to the RDS instance using the MySQL client with the endpoint address, username, and password using this command:
mysql -h <endpoint address> -P <port.no> -u <username> -p

  • Now run these commands to create a database and user.
CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'wordpress-pass';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpress;
FLUSH PRIVILEGES;
Exit

  • Now, install apache2.
sudo apt-get update && sudo apt install -y apache2
  • Let’s check the public IP URL to view Apache2 web page.

  • Install WordPress on the server.

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

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

  • Update the WordPress configuration file (wp-config.php) with the database connection details using vim wp-config.php

  • Edit the database configuration by changing the following lines:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
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' );

  • Copy the extracted WordPress files to the Apache web server document root:
sudo cp -r wordpress/* /var/www/html/

  • Now, restart the Apache web server:
sudo systemctl restart apache2

  • Navigate to <public IP>/wp-admin/ to view the WordPress website.

  • Now we can create a user in the WordPress site to get going in the application.

"Thank you for enjoying my DevOps blog! Your positive response fuels my passion to dive deeper into technology and innovation.

Stay tuned for more captivating DevOps articles, where we'll explore this dynamic field together. Follow me on Hashnode and connect on LinkedIn (https://www.linkedin.com/in/som-shanker-pandey/) for the latest updates and discussions.

Did you find this article valuable?

Support Som Pandey's blog by becoming a sponsor. Any amount is appreciated!