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.
Task-01
- As WordPress requires a MySQL database to store its data, create an RDS as you did on Day 44
To configure this WordPress site, you will create the following resources in AWS:
An Amazon EC2 instance to install and host the WordPress application.
An Amazon RDS for MySQL database to store your WordPress data.
Set up the server and post your new WordPress app.
Read this for a detailed explanation Happy Learning :)
Step 1: Creating an RDS Database
- Create the EcC2 instance first and start creating the RDS database, which I have already shown and created on Day 44
Template
Settings
Instance configuration
Storage
Connectivity
Click on create database
Step 2: Configuring WordPress on EC2 Instance
Connect to the EC2 instance(Ubuntu) and Enable port no 3306 for MySQL
in Security inbound rules
Install MYSQL client on Ec2 machine
sudo apt install mysql-client -y
After Installing MYSQL, run the below command to connect to RDS
mysql -h <rds-database-endpoint> -P <port-no> -u <user> -p <password>
- Create a Database for WordPress and grant access by using the below commands
CREATE DATABASE wordpress;
CREATE USER 'wordpress' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress';
FLUSH PRIVILEGES;
exit;
- To run a WordPress application, you need to run a web server on your EC2 instance. So we will install and start apache2
sudo apt-get install apache2
sudo systemctl restart apache2
- Once it is installed access the apache2 server with InstancepublicIP:80
- Download the WordPress app and extract it.
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
- Copy the WordPress files to the Apache document root directory
$ sudo cp -r wordpress/* /var/www/html/
- Rename the WordPress configuration file and add your database details by running the following command
$ cd /var/www/html
# Rename the config-sample.php
$ sudo mv wp-config-sample.php wp-config.php
$ sudo nano wp-config.php
In the wp-config.php file, replace the following lines with your database details
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');
define('DB_HOST', 'localhost');
with
All these details come from Step 4
DB_NAME: WordPress Database name
DB_USER: Name of the user you created for the WordPress database
DB_PASSWORD: Password for the WordPress user
DB_HOST: endpoint from the RDS database we created
Configure is the Authentication Unique Keys and Salts.
You can replace the entire content and replace with this
define('AUTH_KEY', 'H&|6E`hwKfr{:%)c/VnnD`_juO2G-x5%ja|%aG^o6reM^5-82YAk$?-ScRV(l~*U');
define('SECURE_AUTH_KEY', '+)PXuaoX4 ,!@P)w+b$th=dWerlvoo=|<hBM2-QK@+G<hE<!04/!H;8>Cq5;GPDl');
define('LOGGED_IN_KEY', 'PCXFt:mB+i+jnQGP@m~fkgLaLrR%Q@J*>$M} tUj1U|k2;my])l1!M{E/sQ)(CCY');
define('NONCE_KEY', 'h?t[<nk|:T?AWMJAQGxa`{%pEZ|rc}08zO9pOZl~V{3>XB~<q?ac$+_!%|+Cc<?)');
define('AUTH_SALT', 't, E$7#wcey47lR=`_Yyi]u-E?.j%.MC_Hx0{iV+T[iBj[w)q!JD4Y?+:$_!a+|&');
define('SECURE_AUTH_SALT', 'uMDw+%k5dEY#|`&w!SoH@::~<@jCyG>yP=Rcv^`NN1,+)K:Buv+J-~Y}olc}`-tT');
define('LOGGED_IN_SALT', 't+W]CZ684~.aOve+-,g2x&TI+q,QJ&5E}<q9x;sLx$+[t<+t9VC-ZMD7~8`%+@--');
define('NONCE_SALT', 'DBr&#AO/#|tGwm|wv0L@X^|>7i #DiFc^gnq;uO +8v5az3lh8*/ u6yQ!1v^-jH');
# Installing dependencies for Wordpress
$ sudo apt install php libapache2-mod-php php-mysql -y
$ sudo systemctl restart apache2
Browse "ec2-public-ip/wp-admin/" you should see the WordPress welcome page.