In the digital age, your website isn’t just a virtual storefront; it’s often the very heart of your business, serving as a portal for engagement, commerce, and connection. To ensure that your website not only survives but thrives, harnessing the scalability, resilience, and flexibility of the cloud is essential. And when it comes to cloud infrastructure, Amazon Web Services (AWS) stands as a beacon of innovation and reliability.
As an AWS DevOps engineer, I’ve had the privilege of architecting and managing countless web hosting environments for businesses of all sizes. In this comprehensive guide, we’ll delve into the world of AWS and unveil the art of hosting your WordPress website with precision and expertise.
Whether you’re a startup eager to carve your digital footprint, a growing enterprise looking to scale gracefully, or even an individual blogger seeking performance and security enhancements, this blog series is designed to equip you with the knowledge, best practices, and real-world experiences necessary to navigate the AWS ecosystem successfully.
So, fasten your seatbelt, because we’re about to embark on a journey that will transform your WordPress
hosting experience, making it faster, more secure, and fully optimized for the demands of the modern web. Welcome to the world of AWS-powered WordPress hosting—a world where your website’s potential knows no bounds.
Let’s begin this adventure together, where the cloud meets code, and where your WordPress site becomes a digital masterpiece hosted in the AWS cloud.
Services Used:
- AWS EC2
- Route 53
Step 1: Launch an EC2 instance.
We are going to follow the traditional way of launching the EC2 instance and installing WordPress on it.
On EC2 console, Click “Launch Instance”
- Instance Name: WordPress Server
- Application and OS Images: Ubuntu
- Instance type: t2.micro
- Keypair login: If you have keypair already launched, use existing one or create a new key-pair.
- Network Settings: Select “Create Security Group” and
- Enable: Allow SSH
- Enable: Allow HTTPS
- Enable: Allow HTTP
- Keep Auto-Assign Public IP Enable
- Rest: Keep default settings.
And Launch the instance. After launching and running the isnatcne it will look something like this.
We need to assign Elastic IP to the instance. Navigate to the Elastic IP Section and Allocate and associate an Elastic IP to our instance.
And click on “Allocate”.
Select the allocated Elastic IP and Click on “Actions”, “Associate Elastic IP Address”, select “Instance”, Choose the Instance and click on Associate.
Now we need to login(SSH) into the instance. We will use MobaXterm app to login.
After logging successfully into EC2 instance.
We will run a set of commands on it.
- Install Apache server on Ubuntu
sudo apt install apache2
Now to going to the Public IPv4 IP address of browser, you will see apache home page.
- Install php runtime and my-sql connector
sudo apt install php libapache2-mod-php php-mysql - Install MySQL server
sudo apt install mysql-server
In order to install wordpress we need to create credentials for my-sql server.
MySQL is a critical component of a WordPress website running on an Amazon EC2 instance for several reasons like
DB Management, Data Storage, Data Retrieval, Data Integrity, scalability, Customization, Compatibility, etc
- Login to MySQL server
sudo mysql -u root
- Change authentication plugin to mysql_native_password (change the password to something strong)
ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password by ‘Testpassword@123’;
- Create a new database user for wordpress (change the password to something strong)
CREATE USER ‘wp_user’@localhost IDENTIFIED BY ‘Testpassword@123’;
- Create a database for wordpress
CREATE DATABASE wp;
- Grant all privilges on the database ‘wp’ to the newly created user
GRANT ALL PRIVILEGES ON wp.* TO ‘wp_user’@localhost;
- Download wordpress
cd /tmp
wget https://wordpress.org/latest.tar.gz
- Unzip
tar -xvf latest.tar.gz
- Move wordpress folder to apache document root
sudo mv wordpress/ /var/www/html
Since we have downloaded the .tar file, unzipped it and moved to the /var/www/html directory.
Now, <Instance IPv4/wordpress> of the instance in browser will take to the installation page of wordpress. It will look something like this.
In the next blog we will go ahead and install WordPress for website and look for other details.