AWS WordPress 4: Install WordPress


This post is the fourth of a 5-post series with step-by-step procedures that I followed recently to setup WordPress on AWS for this version of the website. In this post, WordPress is installed onto the AWS instance. Three main steps are needed to install WordPress: setup a WordPress database in MySQL, create a site configuration file for Apache to host WordPress, and install WordPress.

To create a database named ‘wordpress’ in MySQL replacing the pwd with the real password established during installation of MySQL. Note the semicolons in the lines with the MySql commands:

mysql –u root –p


create database wordpress;
grant all privileges on wordpress.* to user2@localhost identified by "pwd"; 
flush privileges;

To create a site configuration file for Apache to host WordPress, change to the following directory:

cd /etc/apache2/sites-available

Create a site configuration file using the nano editor:

sudo nano wordpress.conf

and enter the following (replace with real site domain name):

<VirtualHost *:80>
  DocumentRoot /var/www/wordpress
  DirectoryIndex index.php
  <Directory /var/www/wordpress/>
    AllowOverride All
    Order Deny,Allow
    Allow from all

Enter ctrl-x, type y, and return to save.

Then enable the wordpress configuration and restart Apache2.

sudo a2enmod rewrite
sudo a2ensite wordpress
sudo systemctl restart apache2

To download WordPress, install, and configure, start with this set of commands.

Set Apache2 web server permissions on the ‘/var/www’ directory:

sudo chown www-data:www-data /var/www
cd /var/www

Download WordPress, expand archive and change permissions:

sudo wget
sudo tar –xzvf latest.tar.gz
sudo chown –R www-data:www-data wordpress

Temporarily, set the permissions on wordpress as shown:

sudo chmod –R 777 wordpress

Remove the downloaded file:

sudo rm latest.tar.gz

To verify if the WordPress installation was successful, enter the Elastic IP address (http://xx.xx.xx.xx) into a web browser and, hopefully, see the familiar starting page for WordPress setup:

After selecting the language, an informational page is displayed. All of the requested information was defined during the previous installation steps. Replace username with the real username (user2 in this example) and password with the real password. The default values in the other fields are valid.

If information confirmation is successful, then the following WordPress screen is displayed:

Fill in the requested info and click on ‘Install WordPress’.

Lock down the permissions for the wordpress directories and files:

sudo find /var/www/wordpress/ -type d –exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f –exec chmod 644 {} \;

A line should also be added to the ‘wp-config.php’ file:

sudo nano /var/www/wordpress/wp-config.php

Add this line just above the “stop editing” line:

define(‘FS_METHOD’, ‘direct’); //for automatic plugin installation

Enter ctrl-x, type y, and return to save.
Open a web browser and navigate to ( where ‘’ is replaced with the real website name. Enter the username and password defined during WordPress setup and “Log in”. The WordPress dashboard should be displayed.

2017-08-07T14:00:24+00:00 By |Amazon Web Services, Wordpress|0 Comments

Leave A Comment