Deploy WordPress website on AWS

Abhiraj Thakur
5 min readOct 15, 2023

--

What is WordPress:

WordPress is a free, open-source content management system (CMS) that allows users to create and manage websites.
WordPress is written in PHP and uses a MySQL database. It’s a popular tool for individuals without any coding experience who want to build websites and blogs.

Deploying WordPress website on AWS:

Deploying your WordPress website on AWS, you will require the following AWS service:
1. AWS EC2: Server for running WordPress.
2. AWS RDS: Relational MySQL database.

Prerequisites:

  1. AWS account:
  2. AWS EC2 and AWS RDS are connected with each other. I cover it in my previous blog, you can refer to it here.
  3. Installed PHP-related Apache server based on Ubuntu.
 sudo apt install php libapache2-mod-php php-mysql

This command allows you to install PHP and its essential components, to make your system ready to host and run PHP applications or websites with MySQL database connectivity.

Procedure:

Step 1:

Download the zip file from the WordPress original website using weget command.

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

This command will download the WordPress in .tar format, and you need to unzip the file.

Step 2:

To unzip the .tar file use the below command:

tar -xvf latest.tar.gz

This command will unzip the tar files and a new folder will be created by the name wordpress.

Step 3:

You need to move this wordpress folder to the location /var/www/html as by moving into that location, we can host the WordPress website

Command:

sudo mv wordpress / /var/www/html

Now, copy the ip address of your instance open the web browser past it and navigate to /wordpress, which will open the welcome page.

Click on Let's go,button.

Step 4:

After this, the configure to a database page will be open where you have to enter the following details:
1. Database Name
2. Username
3. Password
4. Database Host

Paste the RDS database that you created with the root username and root password and then paste the database endpoint provided by RDS.

Step 5:

After WordPress gets connected to RDS, you will see an error as the wp-config.php file is missing.

Navigate to /var/www/html/wordpress/,create wp-config.php file and paste the following rules:

<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
*
* @package WordPress
*/

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'day45' );

/** Database username */
define( 'DB_USER', 'admin' );

/** Database password */
define( 'DB_PASSWORD', '1234567890' );

/** Database hostname */
define( 'DB_HOST', 'day45.cnjuamvli1vs.us-east-1.rds.amazonaws.com' );

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );

/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', 'rhd_4_8G`h~<|)a~XN96q}&vrFwrz7gOnShxFU D5Hd]L#mrWq=Gs1o@4^8Wx6XE' );
define( 'SECURE_AUTH_KEY', '=_bmk`N}CT3$VpONcA<XY@NxN^3Sh4bH^vp4akR<HAoA$6_f>Yn*I2J(OMtD;O~7' );
define( 'LOGGED_IN_KEY', '@D1zw- qTAR$9c{2}`**d4yp&izT^+B`:Y#E&hSN=G;}&.s(:{E`_5<&3J}N-%.v' );
define( 'NONCE_KEY', '6wjv-n9SG$WnqMaOfyVbv:E^M2;&Mfv|_$}{*Hqz?snkON9gL].w*lSIDT<<#Xa6' );
define( 'AUTH_SALT', 'd5w597}T@D.6z_?c?}Er7x/uJ}*j2?>j.`)x`B-SCp`wpOE5DJD`tsNNhuiepfFh' );
define( 'SECURE_AUTH_SALT', '=sC9(nznCx-(Vy_,G*A[=O;C73Jxs]!p=R_5{<@E,,WGX$]<Wm]?J5@@F[fgM_*0' );
define( 'LOGGED_IN_SALT', '71swYWF(+##`6T(fKy9kg6zL9)YrwjSXd0jO~YV[I>^c]42.kJM3357)!G1op]Eg' );
define( 'NONCE_SALT', 'Zwt84KHHzhztV=oc/$M3!SSy.YU$/o4}Ud4%)t/Qj#e]nhwR.v>+M.F|8^4^3vFh' );

/**#@-*/

/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';

After that, you would be forwarded to the installation process.

Step 6:

Enter the needed information like Site title, username, password and email.

Click on install wordpress.

Step 7: Login to the Dashboard

Login to your dashboard where you can manage and create your website.

Step 8:
To see your running website, in your browser go to ip address/wordress, where you can see that your website is running and hoisted.

This is the sample website and you can change the contents in your dashboard.

--

--