
In this tutorial, you will learn how to host your WordPress on AWS in a slow way and fast way. To instantly get to know what we will explain below, take a look at this time-lapse video.
We installed WP on AWS first and it took a long while to do it and then there is a faster way by using Cloudways to host AWS which took merely 5 minutes to get to the WP Admin area.
Nearly half of the active websites on the internet use WordPress to power their websites, and for a good reason. To begin with, it’s open-source, which basically means you can use it for free. Furthermore, it’s search engine friendly, allows tons of customization, has huge community support, along with many other reasons why WordPress should be your go-to CMS!
Content is king, and WordPress is one of its grandest castles. However, you do not build castles on just any piece of land. You pick the choicest of territories. In the world of cloud hosting, knowing how to host WordPress on an AWS cloud server could prove to be a game-changer.
I have split the scope of this article into two parts; First, I’ll show you how to install your WordPress application on the AWS-EC2 server (native AWS) and the other with a managed cloud hosting platform like Cloudways. The first part is a very technical method where I will run various commands to install packages and WordPress applications. However, with a second method via Cloudways, you can quickly deploy your server and install your WP application with a few clicks.
Before moving to the actual installation process, you must understand why AWS might be the right choice for hosting your WordPress sites.
Also, you must have a clear stance on why you should choose Cloudways over native AWS hosting.
Therefore, I would recommend you to check the comparative review of shared hosting vs. dedicated hosting vs. managed hosting to help you make an educated decision.
Why Choose Amazon Cloud?
In the cloud industry, Amazon Cloud is known for its reliability and uptime. Many of its data center locations have almost 100 percent uptime. This means websites hosted on Amazon will almost never go down. Amazon Web Services (AWS) is perhaps the most popular cloud hosting provider today.
Facebook, the social media giant home to profiles of more than 2 billion people, hosts the bulk of its business infrastructure on Amazon Web Services, which should give you an idea of the robustness of Amazon’s cloud service.
Managing a Server Via AWS
However, configuring Amazon Cloud is not easy unless you are a cloud wizard (or expert). The black command interface holds a lot of promise, but it’s only friendly to those who know their way around it, or those who can shell out serious money to hire the ones who do.
So what should you do? Learn the command line interface, deploy the stack (LAMP, LEMP, etc), and install WordPress.
For instance, you’ve learned how to host a WordPress application on an AWS server but still what you’ll do for the security, how could you optimize your stack, how are you going to backup your site, how will you handle the server attacks, and how will you manage the other basic and advanced essential configurations.
I always appreciate people learning new things, but if you’re running a serious online business and time is more vital for you, I would say Cloudways is the best option. It has a team solely focused on managing Amazon cloud instances, which means your Amazon servers get regular updates for OS and firmware without any effort on your part. Plus, a layer of security protocols ensures the protection of your Amazon Web Services instance.
Managing a Server via a Managed Hosting
A managed AWS WordPress hosting provider takes away all the hassles of server management and allows you to focus on your WordPress websites. Cloudways ensures smooth server performance and addresses maintenance issues as soon as they arise, you can ask our product specialists anything by requesting a Cloudways demo.
Finally, Cloudways keeps a close eye on your WordPress hosted on the AWS server’s security so that your site is protected from cyber attacks that continue to plague the ecommerce industry. To sum it up, if you are not interested in dealing with server management issues, but still wish to use WordPress on AWS, managed Amazon WordPress hosting solutions such as Cloudways fit the bill perfectly.
You can install WordPress on the AWS server on Cloudways rather easily. However, let’s dig deeper into why Cloudways is the best solution for you!
Why Choose Cloudways for Amazon Web Services?
Installing WordPress on an AWS server is no walk in the park. You should know your way around some techy Linux commands as by default AWS server does not come with any Graphical User Interface to work with. This means everything is done via CLI which can cause complexity in setting up the server if you are not familiar with server-side knowledge.
Being a managed cloud platform, Cloudways eliminates the complex server configuration process and lets you launch AWS servers in just a few clicks. Cloudways also takes care of managing the server as well as offers tons of utilities that allow you to integrate other services conveniently.
It offers a unique value proposition where it uses Apache and NGINX to help boost your site performance along with MariaDB as a database, Linux as an operating system, and PHP. Combining these all technologies, the Cloudways performance-oriented stack is specially designed to improve your site performance.
Also, Cloudways offers a ready-made solution for integrating SSL, CloudwaysCDN, and application monitoring by New Relic. The Cloudways platform also gives its customers the facility to manage features like creating staging sites, website cloning, bot protection, adding team members, and managing cronjobs in just a few clicks. Also, it provides efficient and fast WP hosting on its managed platform.
Performing such operations directly on an AWS server requires a series of commands and troubleshooting in case you face any issues.
Now, you know what’s the reason and why people choose Cloudways for AWS WordPress hosting. So, let’s get started and see how to launch an AWS server and WordPress on AWS platform (EC2) and Cloudways.
1. How to Install WordPress on AWS EC2 Platform (Without Cloudways)
Video Tutorial:
The signup process is really simple, so I’ll skip this process and assume that you already have a new AWS account. One more thing, after the signup, you’ll be required to verify your account by using a credit card.
Step 1: Launch and Setting up EC2 Instance on AWS
The first thing you need to do is set up an AWS-EC2 instance and for this, click on Services > Compute > EC2 to install a virtual server on a cloud.
Then, a new screen, “EC2 Dashboard” will appear on your browser, and next, you need to click on Instances > Launch Instance.
After that, you need to select an operating system for your server and I’m going with Amazon Linux 2 AMI.
Next, the instance-type section will appear from where you can select the number of vCPUs, RAM, and instance type for your server. You’ll see, by default, it will be selected as a t2.micro instance. So, just click Next.
Then, a new section will appear from where you can check and configure your instance details. Just click Next, no need to change any details.
You can add a new volume in the storage section, increase the volume size, and other storage-related settings. Here, you don’t need to change anything, just simply click Next.
Next, click on Add Tag and fill the Key and Value field then click Next. In my case, Key = Name and Value = FarhanCloudways.
The next section is a security group configuration. Here, you can set a name for your security group and add the description. Also, you can add new rules and set the access point (IPs) for each.
Here, you have to give your security group a name and add the description in the respective field.
Next, click on the Add Rule button and select SSH. Repeat the same to add HTTP and HTTPS. After that, you have to change the Source and I’ve selected Anywhere as you can see in the image below.
After setting the security group configuration, you can click the Review and Launch button.
This is the last section from where you can review your instance (Storage, Tags, etc) and create a new key pair.
The first thing you need to do is click Launch and select Create a new key pair. After that, fill the key pair name field and click Download Key Pair.
After downloading the key pair, you can click Launch Instances to launch your virtual server.
Tada! You’ve successfully launched your EC2 instance.
Step 2: Convert PEM file to PPK and Access your Server Via PuTTY
I assume that you already have PuTTY and if you don’t have, then download it from this link “Download PuTTY”.
Next, you have to launch PuTTYgen and for that, search PuTTYgen on your windows search bar and click Open.
Next, you need to click Load and select the PEM file you have previously downloaded while launching the EC2 instance.
Next, click Save private key and download the PPK file to your desktop.
And the PPK file will look like this.
You’ve successfully converted the PEM file to PPK and now, you can use this PPK file to access your cloud server. So, let’s do it.
Open PuTTY and type “[email protected]”
Where,
Ec2-user: Default user.
Your IP address: The public IP of your server.
Next, navigate to Connection > SSH > Auth and click browse and select the PPK file that you have recently downloaded from PuTTYgen.
Then, click Open and access your virtual cloud server(EC2) via PuTTY.
Step 3: Deploy the LAMP Stack
You have an empty server that’s why first you need to deploy a stack that will provide you a platform to run your web applications. In this article, I’m going to deploy the LAMP stack (Linux, Apache, MariaDB/MySQL, and PHP).
You can also do it yourself or hire international contractors from less expensive countries to configure this for you, though it makes the process more tedious.
To install the LAMP stack, run the following commands.
sudo su
For the root access.
yum install httpd
To install the Apache web server.
systemctl start httpd.service
To start the Apache web service.
systemctl enable httpd.service
To enable the apache web service to start automatically on boot.
Now, run your public IP on the browser to check the successful installation of Apache. If you see the following image then it means it has successfully installed.
yum install mariadb-server mariadb
To install MariaDB as a database.
systemctl start mariadb
To start the MariaDB service.
mysql_secure_installation
Improve the security of your MariaDB installation.
Note: At first, it will ask for the root password and you just have to press “Enter” (By default, there’s no root password).
If you want to set the root password for your database then press “y” and simply update it.
systemctl enable mariadb.service
To enable the MariaDB service to start automatically on boot.
amazon-linux-extras install php7.3
To install PHP.
systemctl restart httpd.service
Restart the Apache webserver.
vi /var/www/html/farhan.php
Create and edit a file on your defined path.
After this, you need to paste (mouse right-click) the following code in the file and press “ESC” and type “:wq!”.
<?php for ($count=1; $count<=9; $count++) { echo " $count times 9 is ". $count*9; echo "<br>"; } ?>
Let’s run the newly created PHP file on your browser “http://yourIPaddress/farhan.php”.
Step 4: Install WordPress Application
After the LAMP stack deployment, the next step in the process is to install the WordPress application. Here, all you need to do is run the following commands.
mysql -u root -p
To access the root account.
After running this command, you have to provide the root password that you have set up in the previous step (root password is required to access DB).
CREATE DATABASE farhandb;
Create a new database for WordPress.
CREATE USER [email protected] IDENTIFIED BY ‘password’;
Create a new user (named as farhanuser) and assign the password.
GRANT ALL PRIVILEGES ON farhandb.* TO [email protected] IDENTIFIED BY ‘password’;
Grant full control (database) to a user.
In my case, the DB name is “farhandb”, the username is “farhanuser” and the password is “password”.
FLUSH PRIVILEGES;
Changes to take effect without restarting the DB service.
Then, run the “exit” command.
cd /var/www/html/
Change the current working directory to the HTML folder.
wget https://wordpress.org/latest.tar.gz
Download the latest WordPress file.
tar xzvf latest.tar.gz
Extract the archive file.
chown -R apache:apache /var/www/html/wordpress/*.
Assign ownership to WordPress files and folders.
cd wordpress/ and run this command: cp wp-config-sample.php wp-config.php
Create a copy of wp-config-sample.php (named as wp-config.php).
nano wp-config.php
To edit the wp-config file.
Now, change the value of the DB_NAME, DB_USER, and DB_PASSWORD to connect the database with your WP application.
After this, run your WordPress file URL “http://yourIPaddress/wordpress” on the browser. Then, you’ll see the basic WordPress installation setup screen.
You’ve successfully installed the WordPress application on an AWS server so, next, you need to log in to your WP account.
Now, it’s time to see how easy it is to launch an AWS server and WordPress on Cloudways.
Sure Your Hosting Provider Isn’t Charging Extra?
Use the Web Hosting Savings Calculator for FREE to instantly find out the ideal host that fits your requirements best.
2. How to Install WordPress on AWS With Cloudways
Video Tutorial:
Let’s learn how to host WordPress on AWS through some easy steps on Cloudways:
Sign up for Cloudways
First, you need to sign up for a Cloudways Account if you haven’t already. Simply enter the required details and click the Start Free button.
Now verify your email address and then log in to your account. There, you should click on the Launch button.
Select WordPress
Choose the latest version of WordPress from the list of available applications. Name your application, server, and select your project.
Note: You have the choice of launching Cloudways Optimized WordPress, WordPress with WooCommerce, WordPress Multisite, and WordPress without any optimization.
Select Server
Pick Amazon Web Services from the list of cloud infrastructures as a service.
Select Server Size
Select your server size from the available options. If you hover on any of the server sizes, you can see its RAM and CPU size as well.
Select Bandwidth
Select the estimated bandwidth usage of your WordPress website.
Choose Disk and Database Storage Size
Choose the storage sizes for Application Files and Database.
Choose Data Center Location
Amazon Cloud comes with a lot of location choices. The best practice is to host your WordPress website nearest to the target audience since it reduces load times.
Launch Your Server
You’re done! Just press Launch Now to begin configuring your server.
Now, wait till your server is ready!
Once your server is ready, click on Applications from the top menu bar.
Now click on your WordPress application.
Go to Application Management → Access Details → Admin Panel to get your WordPress login credentials.
That’s it! You have successfully launched WordPress on AWS server on a staging environment.
Exploring Server Tabs – Cloudways
As explained earlier, Cloudways is an intuitive platform. Let’s have a look at its Server Dashboard.
Inside Server Management, we have several tabs on the left side of the window.
This dashboard contains the following useful tabs:
Master Credentials
This tab contains the Public IP of your server as well as master credentials. You may also create a public SSH key from this tab and this also has the link to Cloudways integrated SSH terminal.
Monitoring
As the name suggests, this tab is useful for monitoring your server’s resources such as disk usage, RAM usage, CPU usage, and the timeline displaying resource utilization over the period from 1 hour to 6 months.
Manage Services
This tab contains the control switches of various packages and software running on your server. Such as Apache, MySQL, Memcached, New Relic, Nginx, and Varnish.
Security
By using this tab you may whitelist IPs for both the SFTP and MySQL connections.
Backup
Website backups can be controlled using this tab. This allows you to take manual backups and set a frequency for automated backups.
Exploring Application Tabs – Cloudways
Similar to the Server Management service, Cloudways also offers Application Management Dashboard for managing an individual application on a server.
The Application Management dashboard contains the following useful tabs:
Access Details
This tab contains access credentials as well as direct URLs for your WordPress site and its wp-admin. You may also create additional credentials for SFTP connections.
Domain Management
It is used for domain/subdomain mapping.
SSL Certificate
Cloudways offers a FREE SSL Certificate via Let’s Encrypt which can be added easily using this tab. If you wish to use your own certificate, you can also upload it from here.
Application Settings
This tab contains useful controls related to the application such as permissions, SSH access, PHP FPM settings, and Varnish settings.
Migration Tools
Cloudways offer multiple ways of moving WordPress sites from your old server to the Cloudways AWS server. One such option is the Cloudways migrator plugin which lets your WordPress site migrate to cloud computing easily.
Taking WordPress Site Live on AWS – Cloudways
Just like other tasks, Cloudways also simplified the process of taking the WordPress site live. All you need to do is to visit your Application Management dashboard and go to the Domain Management tab.
Enter your domain name and add the CNAME inside your domain registrar. Let it propagate and once it’s done, your WordPress site will start serving from your primary domain. You may also map your subdomains using the same tab.
Wrapping up!
Now, you know the easiest way to host your WordPress site and why Cloudways is a better option when it comes to hosting your WordPress site on an AWS server.
The WordPress optimized hosting server stack on the managed AWS cloud is made up of Apache and NGINX web servers with Varnish and Memcached optimization. You can enable the Redis cache as well. Plus, you can integrate Elasticsearch on the WordPress website.
Customer Review at
“Beautifully optimized hosting for WordPress and Magento”
Arda Burak [Agency Owner]
Farhan Ayub
Farhan is a community manager at Cloudways. He loves to work with WordPress and has a passion for web development. Mostly, he spends his time interacting with the people in the WordPress community. Apart from his work life, Farhan spends his time gaming and playing sports. Feel free to contact him at [email protected]