MSP Medium
6 min readNov 8, 2023

Embark on your digital journey with our step-by-step WordPress setup tutorial. Unlock the power of customization, create stunning websites, and dive into the world of blogging effortlessly. Whether you’re a tech novice or a seasoned pro, our guide ensures a smooth setup process, empowering you to bring your online vision to life with WordPress magic!

In this tutorial, we are going to set up a WordPress blog in our AWS Ubuntu EC2 instance.

You can read this tutorial for hosting WordPress using Bash Script.

Step 1: Create an EC2 instance with Ubuntu 20.04 AMI

The first step we take is to log into the AWS console with proper credentials. We need to find the EC2 service from the service catalogue. Then, we need to click the launch instance button, configure as needed, and finalize by clicking the Launch Instance button again.

Step 2: SSH into the instance

I am using Windows local machine which is why I prefer to use Putty for performing SSH into the EC2 instance. We need to open Putty application and configure for SSH connection with the Hostname being user’s name in the EC2 instance and DNS

ubuntu@<Public DNS of EC2 instance>

Then, the private key need to be provided and connection can be established.

Step 3: Install Apache, MySQL, and PHP

Before setting up WordPress, we need to lay down the groundwork. Here that is to install Apache web server, MySQL database and PHP.

sudo apt update -y
sudo apt upgrade -y
sudo apt install -y apache2 mysql-server php libapache2-mod-php php-mysql

Step 4: Change the Apache document root directory

This step is necessary for later stages. The default document root for Apache Web server in Ubuntu is /var/www/html. If we want to set up a directory with the name WordPress and put the files in it and also be able to access the site directly from Public IP of instance, we need to change the default directory to /var/www/html/wordpress.

Step 5: Change the Apache directory settings to allow overrides

This step is as simple as the name suggests. We just need to allow overrides in the /var/ww directory fom apache.conf file.

Step 6: Create a MySql database and user for the WordPress site

Access the MySQL database, create a database for the WordPress site, and a user with privileges to access and make changes to it.

sudo mysql;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';

To verify the presence of the database and user:

SELECT user FROM mysql.user;

Step 7: Download and extract the latest version of WordPress

Download the latest version of WordPress site. Then unzip the file and move the contents to /var/www/html directory.

sudo wget
tar xzvf latest.tar.gz
sudo mv wordpress /var/www/html/

Step 8: Set the correct permissions for the WordPress files

This is an unavoidable step. Here, we need to give the ownership of the WordPress directory to Apache Web Server i.e. www-data user and www-data user group.

Additionally, to make any changes to the files from our WordPress site, we need to give write permission too for the WordPress directory.

sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

Step 9: Create a wp-config.php file from the sample file

As we have previously created MySQL database and user for our WordPress site, we need to configure them for use too. For that we need to edit wp-config.php file. But we there is a sample only in downloaded files, we need to copy that file and rename it wp-config.php and add proper details and credentials.

cd /var/www/html/wordpress
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php

Step 10 : Restart apache and view output

Finally, save the config file, reload Apache server and access the WordPress site and Voila!!

sudo systemctl restart apache2

Author: Sanjeeb Nepal