๐ Building a WordPress Site on AWS EC2 (Amazon Linux): A Comprehensive Manual

Table of contents
- ๐ What Weโre Building
- ๐ ๏ธ Step-by-Step Installation Guide
- You can verify them with as seen above:
- ๐ฆ Step 2 โ Install Required Software
- ๐ Step 3 โ Enable and Start Web & Database Servers
- ๐ Step 4 โ Secure the MariaDB Root Account
- ๐ Step 5 โ Download and Install WordPress
- โ๏ธ Step 6 โ Configure WordPress
- ๐งฑ Step 7 โ Create WordPress Database and User
- ๐ Step 8 โ Launch in Browser
- ๐จ Troubleshooting Tips
- ๐ฏ Conclusion

Fed up with one-click WordPress installers? This comprehensive guide walks you through setting up WordPress manually on an AWS EC2 instance, giving you full control over your server environment. Perfect for developers who want to understand the underlying stack!
Setting up WordPress on an EC2 instance manually gives you full control over your hosting stack. In this post, Iโll walk you through the complete process of installing WordPress on AWS EC2 using Amazon Linux, Apache, PHP, and MariaDB โ all without automated tools.
Whether you're a DevOps beginner or just prefer doing things manually, this guide has you covered.
๐ What Weโre Building
Weโll manually set up a WordPress site on an Amazon EC2 instance using the LAMP stack:
LAMP stands for:
Linux โ OS running on your EC2 instance (Amazon Linux 2)
Apache โ Web server
MariaDB โ MySQL-compatible database
PHP โ Server-side scripting language that powers WordPress
By the end, youโll have:
โ
A working WordPress website
โ
Database and credentials securely configured
โ
Apache and MariaDB running and enabled at startup
โ
Everything accessible via your EC2 instanceโs public IP
Before you begin, ensure you have:
An AWS account
A key pair for EC2
Basic familiarity with the command line
Open ports for HTTP (80), SSH (22), and optionally HTTPS (443)
To start we created a โstackโ with preconfigured parameters from the manual below:
Alternatively, you can use AWS CloudFormation to create a stack by inputting the necessary parameters.
Navigate to EC2 on the AWS console and click on the Instance created alongside the stack.
Connect to the instance using AWS linux terminal
๐ ๏ธ Step-by-Step Installation Guide
๐ Step 1 โ Set Database Credentials as Variables
DBName='a4lwordpress'
DBUser='a4lwordpress'
DBPassword='4n1m4l$4L1f3'
DBRootPassword='4n1m4l$4L1f3'
You can verify them with as seen above:
echo $DBName
๐ฆ Step 2 โ Install Required Software
sudo dnf install wget php-mysqlnd httpd php-fpm php-mysqli \
mariadb105-server php-json php php-devel -y
๐ Step 3 โ Enable and Start Web & Database Servers
Make sure the services start now and on reboot:
sudo systemctl enable httpd
sudo systemctl enable mariadb
sudo systemctl start httpd
sudo systemctl start mariadb
๐ Step 4 โ Secure the MariaDB Root Account
Set a password for the MariaDB root user:
sudo mysqladmin -u root password $DBRootPassword
๐ Step 5 โ Download and Install WordPress
Download and extract WordPress into your web root:
sudo wget http://wordpress.org/latest.tar.gz -P /var/www/html
cd /var/www/html
sudo tar -zxvf latest.tar.gz
sudo cp -rvf wordpress/* .
sudo rm -R wordpress
sudo rm latest.tar.gz
โ๏ธ Step 6 โ Configure WordPress
Create the configuration file:
sudo cp ./wp-config-sample.php ./wp-config.php
Replace placeholders in the config with your variables:
sudo sed -i "s/'database_name_here'/'$DBName'/g" wp-config.php
sudo sed -i "s/'username_here'/'$DBUser'/g" wp-config.php
sudo sed -i "s/'password_here'/'$DBPassword'/g" wp-config.php
Ensure Apache owns the web root:
sudo chown apache:apache * -R
๐งฑ Step 7 โ Create WordPress Database and User
Generate SQL statements:
echo "CREATE DATABASE $DBName;" >> /tmp/db.setup
echo "CREATE USER '$DBUser'@'localhost' IDENTIFIED BY '$DBPassword';" >> /tmp/db.setup
echo "GRANT ALL ON $DBName.* TO '$DBUser'@'localhost';" >> /tmp/db.setup
echo "FLUSH PRIVILEGES;" >> /tmp/db.setup
Execute them:
mysql -u root --password=$DBRootPassword < /tmp/db.setup
sudo rm /tmp/db.setup
๐ Step 8 โ Launch in Browser
Visit your EC2 instance's public IPv4 address in a browser:
http://your_instance_public_ipv4_ip
You should see the WordPress setup screen. Complete the installation from there.
Set up page to set your login details
Then login to your Wordpress account
This takes you to your landing page on Wordpress
โ Final Result
You now have a fully functional WordPress site running on a manually configured EC2 instance with:
Apache, PHP, and MariaDB installed
WordPress files deployed and configured
A secure database connection
Web access via your EC2 public IP
๐จ Troubleshooting Tips
403 Forbidden? Run:
bash
sudo chmod -R 755 /var/www/html
Database errors? Double-check
wp-config.php
.Apache not running? Restart it:
bash
sudo systemctl restart httpd
๐ฏ Conclusion
Congrats, Youโve successfully installed WordPress manually on AWS EC2!
Manually installing WordPress gives you insight into how your server works and flexibility in customizing your deployment. This method is great for learning DevOps fundamentals or creating a lightweight, self-managed WordPress host on AWS.
In conclusion, manually setting up a WordPress site on AWS EC2 provides a deep understanding of the LAMP stack and offers full control over your server environment. This approach is ideal for those looking to learn DevOps fundamentals or customize their WordPress hosting. By following this guide, you have successfully installed WordPress, configured a secure database connection, and ensured web access via your EC2 public IP.
This method not only enhances your technical skills but also allows for greater flexibility in managing security and performance and gives you:
โ
Full control over your stack.
โ
Better understanding of the LAMP environment.
โ
Flexibility to customize security and performance.
๐ Want to take it further?
Secure your site with HTTPS (use Letโs Encrypt)
Add a domain name
Create an AMI to replicate the setup
Secure your site with HTTPS (Letโs Encrypt).
Set up automated backups.
Questions? Letโs discuss in the comments!
#WordPress #AWS #EC2 #WebDev #Cloud
๐ Further Reading
Let me know in the comments if you'd like a guide for any of these next steps!
Subscribe to my newsletter
Read articles from Funmilola Elizabet Opeyemi Musari directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Funmilola Elizabet Opeyemi Musari
Funmilola Elizabet Opeyemi Musari
I am a Food Technologist & Sales Strategist turned DevOps Explorer | Leveraging problem-solving and client-centric skills to build resilient cloud systems. Currently mastering CI/CD pipelines, Azure, and Infrastructure as Code (Terraform) to automate deployments like a well-oiled production line. Passionate about merging operational efficiency with technical innovationโbecause great systems, like great recipes, require precision and scalability.