October 26, 2026By Nilesh Lipane

How to Host a WordPress Site on AWS

How to Host a WordPress Site on AWS: A Step-by-Step Guide  

Introduction

Ever thought of how to build your own website and make it available to everyone across the globe without buying a server? 

Today, organizations, bloggers, schools, and software engineers make use of cloud-based platforms to host their websites. Some of the most popular pairs are WordPress and Amazon Web Services (AWS).

WordPress is an open-source CMS, which implies that one will be able to develop websites, blogs, portals, and e-commerce sites without coding. Amazon Web Services (AWS) are cloud computing services, which facilitate the hosting of a website by offering services like Amazon EC2, Amazon RDS, Amazon S3 and Route 53.

In this blog post, we will learn how to host our WordPress website on AWS. We will begin with an Amazon EC2 instance, installing tools, configuring the database, and accessing the WordPress installation page via web browser.

What Is WordPress?

WordPress is a content management system that makes it easier for you to develop and manage your websites. There is no need to write HTML, CSS, and PHP lines for developing your website. WordPress provides you with themes and plugins and a dashboard for your website management.


WordPress can be used to make:

• Personal blogs

• Websites for business

• Educational websites

• Portfolios

• Websites for news

• Online shopping websites

• Training institution’s websites

For instance, a training institution can utilize WordPress to post course information, trainer information, testimonials of students, and technical blogs.

What Is AWS? 

AWS (Amazon Web Services) is an online platform offering cloud computing services.

Whereas a physical server has to be bought, one can get a virtual server in the AWS environment and set up their website on it. Some of the AWS products that would be helpful for WordPress hosting include:

Service in AWS Purpose

  • Amazon EC2 Application runs here
  • Amazon RDS Managed database 
  • Amazon S3 Backups and media storage 
  • Amazon Route 53 Domain name management 
  • AWS Certificate Manager Provides certificates for TLS for integration 
  • Amazon CloudWatch Resource and application infrastructure monitoring 
  • AWS IAM Access and permission management

In our case, for the beginner project, we are going to use the Amazon EC2 service and set up a web server, PHP, and database software on the instance. Separating the database to AWS RDS might help in the future for the production website.

Why Host WordPress on AWS? 

WordPress can be hosted on AWS in a flexible manner as one is able to select the necessary resources and services for their application. 

The main advantages include: 

• Scalability: One is able to scale computing resources based on the growth of their website. 

• Control: It gives one the ability to customize the operating system, web server and application. 

• Security: It has services such as Security Groups and IAM to control access.

• Monitoring: CloudWatch can be used to monitor infrastructure. 

• Global Reach: It has Regions and Availability Zones in different parts of the world. 

• Integration: Integration of WordPress hosting service with other AWS services is possible.

Do keep in mind that having AWS does not necessarily guarantee security or high availability for your website.

Architecture Used in This Project 

The following items will be used in this beginner-friendly lab:

• Amazon EC2 running Amazon Linux 2023

• Apache HTTP Server

• PHP

• MariaDB database

• WordPress application code

• An EC2 Security Group

• A web browser to visit the website

This will be run on the EC2 instance for the website and the database application software for this learning purpose. It is good enough for understanding how to install, but not a good production environment since the database should be separated from the web server.

Prerequisites 

Ensure that you have the following before commencing with the project:

• An AWS account

• Access to the AWS Management Console

• Basic knowledge of Linux commands

• Basic knowledge of EC2 instances and Security Groups

• An SSH client or EC2 Instance Connect access

• A web browser

Note: AWS resources will cost you some money.Before creating the resources, be aware of the cost of the services that will be used, such as the instance type, storage, public IPv4 address, and data transfer.

Step 1: Launch an EC2 Instance 

First, you have to configure a virtual server on AWS.

1. Login to AWS Management Console.

2. Launch the Amazon EC2 service.

3. Click Launch Instance.

4. Name your instance like “WordPress-Server.”

5. Choose the operating system to be Amazon Linux 2023.

6. Specify an instance type for your lab.

7. Configure a key pair for SSH access if required.

8. Set up network and Security Group configuration.

9. Determine the storage size.

10. Launch the instance.

Wait until the instance gets ready and status checks get passed.

If you want to access your website via the Internet, copy the instance’s public IPv4 address.

Step 2: Configuration of the Security Group

The Security Group acts as a firewall for your EC2 instance.The security group determines what type of traffic is permitted to connect to the EC2 instance. <Cite refs={["turn180782search0","turn180782search1"]}/>

In this lab, set up the following inbound rules:

Type Port Source

SSH 22 Your public IP address

HTTP 80 0.0.0.0/0

HTTPS 443 0.0.0.0/0

Port 80 provides users with access to the site using HTTP. Port 443 is used for HTTPS after the configuration of TLS.

SSH should never be opened to the entire Internet unless it is needed for temporary testing purposes. In the case of a real website, limit the access as much as possible.

Step 3: Connection to the EC2 Instance 

Connect to your EC2 instance using EC2 Instance Connect or using an SSH client, depending on the compatibility of EC2 instance. 

After connection, make sure that you have all the updated packages installed by executing: 

sudo dnf update –y 

This will ensure that you have all the updated packages installed.

Step 4: Installation of Apache, PHP, and MariaDB

For WordPress installation, Apache, PHP, and a supported database are required.

In this case, we will be using Apache as the web server and MariaDB as the database.

Execute:


sudo dnf install -y httpd mariadb105-server \


php php-mysqli php-gd php-mbstring \


php-xml php-intl php-zip wget tar


The names of packages might differ depending on repositories in the operating systems. If a certain package cannot be found, refer to the repositories and list of supported PHP packages for your Amazon Linux.


Start Apache and MariaDB:


sudo systemctl enable --now httpd


sudo systemctl enable --now mariadb

Verify their states:


sudo systemctl status httpd 

sudo systemctl status mariadb


If the services have started, then the necessary services are ready for the next step.

Step 5: Installing and Configuring the Database

WordPress requires a database to store content, users, and other relevant information. If there is a utility called “MariaDB security configuration,” execute it:

sudo mariadb-secure-installation 

Answer the questions that will appear on the screen according to your requirements. After that, launch the MariaDB command line: 

sudo mariadb 

Create a database and a user for WordPress: 

CREATE DATABASE wordpress_db 

CHARACTER SET utf8mb4 

COLLATE utf8mb4_unicode_ci; 

CREATE USER 'wp_user'@'localhost' 

IDENTIFIED BY 'REPLACE_WITH_A_STRONG_PASSWORD'; 

GRANT ALL PRIVILEGES ON wordpress_db.* 

TO 'wp_user'@'localhost'; 

FLUSH PRIVILEGES;

EXIT;

Change the example password to something unique before running the commands. The database name will be wordpress_db and the application username wp_user. This information will be required while configuring the WordPress application.

Do not use the root database account for the WordPress application.

Step 6: Download and Install WordPress 

Navigate to the Apache web directory: 

cd /var/www/html 

Get the WordPress software package from its official source: 

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

Unzip the tar ball: 

sudo tar -xzf latest.tar.gz 

The files will be unzipped under the directory called wordpress. 

As a simple lab, one may choose to copy all these files to the web root: 

sudo cp -a wordpress/. /var/www/html/ 

Once done, remove the tar ball and unzipped directory, ensuring that the files have been copied successfully: 

sudo rm -rf /var/www/html/wordpress 

sudo rm -f /var/www/html/latest.tar.gz 

Note: The above command is meant for this lab only. Don’t do this on a live website without verifying its content.

Step 7: Configure WordPress File Permissions 

It should be noted that it is crucial for Apache to have adequate access to WordPress files.

The ownership and permissions for a basic installation can be set using the following command lines:

sudo chown -R apache:apache /var/www/html

sudo find /var/www/html -type d -exec chmod 755 {} \;

sudo find /var/www/html -type f -exec chmod 644 {} \;

As we see from the command lines, ownership and permissions for Apache have been provided. For production use, it is recommended to apply more restrictive ownership and write permissions.

Step 8: Visit the WordPress Setup Page

Let us open our browser and enter the following URL:

http://YOUR-EC2-PUBLIC-IP

Use the YOUR-EC2-PUBLIC-IP and replace it with the IP of your instance.

If the WordPress setup page doesn’t appear, check if:

• Your EC2 instance is running.

• The Apache service is running.

• Port 80 is opened in your security group.

• The WordPress files are located at /var/www/html.

• Your instance is connected to the network.

If all the above conditions are met, the WordPress setup page will appear.

Step 9: Installing WordPress 

Go through the following steps as shown on your screen.

Input the details for the database that you configured:

Setting Value 

Database Name wordpress_db 

Username wp_user 

Password Password you configured for the database 

Database Host localhost 

Table Prefix wp_ or something else appropriate 

Next, enter the details for your website: 

• Title of your site 

• Username for the WordPress admin 

• Admin password 

• Email address for the admin 

Finish the installation and log into the WordPress dashboard. Dashboard URL should be:

http://YOUR-EC2-PUBLIC-IP/wp-admin 

You can start adding pages, posting entries, choosing a theme, and installing the right plugins.

 Step 10: Test Your WordPress Website 

Once the installation process is completed, the following should be tested thoroughly. 

These include:

• The main page loads properly. 

• Access to the WordPress Dashboard. 

• Posting a sample blog post. 

• Uploading images. 

• Website loading upon refresh. 

• The restarting of both Apache and MariaDB when necessary. 

If all goes well, a basic WordPress website on AWS EC2 has been hosted successfully.

 How to Connect a Custom Domain 

If you have a domain name, you can set up your domain name to point to your website. 

The common practice is using Amazon Route 53 or the DNS service from your domain registrar. You would have to create the right DNS record pointing the domain name to the hosting endpoint. 

In case of an EC2 lab setup, you can use a public IP for testing purposes. In case of having a static IPv4 address requirement, you may want toconsider using an Elastic IP address and see the pricing for that. 

For the production environment, it is better to have the domain name configured to use HTTPS rather than a login page exposed through HTTP.

How to Enable HTTPS

HTTPS encrypts all traffic between the user’s browser and the website.

WordPress website in production should have HTTPS set up, particularly when users login or enter data. This can be done through a proper TLS certificate and web server setup.

AWS Certificate Manager gives you the certificates for AWS integration support. But in case of termination of the HTTPS directly on your EC2 server, then you would require an appropriate certificate configuration and renewal system.

After configuring HTTPS, you can test your website whether WordPress is utilizing the correct HTTPS URL.

Important Security Best Practices 

For the installation of WordPress on business websites, certain security measures have to be taken into account, which include: 

• Updating WordPress: Regular updating of the WordPress platform, themes, and plug-ins.

• Passwords: Use of strong passwords for administrator and database.

• HTTPS activation: Avoid transmission of the log-in information over plain HTTP. 

• Restrict SSH access: Provide administrative access to trusted parties only. 

• Backup: Perform backup of the database and web site files. 

• Server Monitoring: Use AWS CloudWatch and OS monitoring if required.

• Avoid the use of too many plugins: Only use those plugins that are reliable.

• Database Credentials: Never share your database password on blogs, screenshots, or any code storage site.

• Recovery plan: Check how to restore the website from backups. 

In case of the production deployment, it is advisable to utilize Amazon RDS for database, Amazon S3 for backups and a more reliable architecture.

Common WordPress Hosting Problems 

The website will not load 

Check the EC2 instance status, public IP, Apache server, route, and Security Group. Database Connectivity Issues 

Check database name, username, password, and database server status. 

One can use the following command for checking MariaDB: 

sudo systemctl status mariadb 

Apache is Not Running 

Check the status of Apache: 

sudo systemctl status httpd 

Analyze logs to find out configuration issues: 

sudo journalctl -u httpd --no-pager -n 50 

Permission Issue in WordPress 

Check permissions and owner. Avoid solving all permission issues by allowing all files to be writeable.

Conclusion 

Hosting a WordPress website using AWS is one of the practical projects that any person who wants to learn about Cloud Computing, AWS, Linux or DevOps should undertake. 

In this particular project, we have set up an EC2 instance, installed Apache, PHP and MySQL and configured a WordPress database. 

We then uploaded the website files and installed the WordPress software via the web browser. 

Some of the other things that you learned during this project include Security Groups, database details, domain setup, HTTPS and security in production. 

The next step would be to enhance the project by splitting the database to Amazon RDS, backing the data up in Amazon S3 and setting up HTTPS.

Author:

Nilesh Lipane

Related Links:

Anthropic AI Tool

What is Writesonic

Career Objectives For Fresher

Resume Tips For Software Developers

Do visit our channel to know more: SevenMentor 

Nilesh Lipane

Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.

#Technology#Education#Career Guidance