Sheet ⁨02⁩ · ⁨Blog⁩Surveyed ⁨2026⁩

Blog post image for How to Install WordPress on Amazon Linux 2 - How to install WordPress on Amazon Linux 2 and configure it to run with Apache, PHP, and MariaDB.

How to Install WordPress on Amazon Linux 2

Published: Updated: 02 Mins read04 Mins listen
Markdown for AI(opens in a new tab)

Careful here

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023 use dnf in place of yum, and install PHP 8 directly rather than through an extras channel.

Introduction

This tutorial installs WordPress on Amazon Linux 2 and configures it to run with Apache, PHP, and MariaDB.

Prerequisites

To follow along with this tutorial, you will need:

Installing WordPress, setting up WordPress, and running a basic WordPress demo

Step 1 Download WordPress

WordPress is a free and open-source content management system (CMS) based on PHP and MySQL. It is the most popular CMS in the world.

To download WordPress, run the following command:

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

Step 2 Extract WordPress

To extract the WordPress archive, run the following command:

Terminal window
sudo tar -xzvf latest.tar.gz

Next, move the extracted WordPress directory to the /var/www/html directory:

Terminal window
sudo mv wordpress /var/www/html/

Step 3 Create a WordPress database

To create a WordPress database, run the following command:

Terminal window
sudo mysql -u root -p

Next, create a database for WordPress:

CREATE DATABASE wordpress;

Next, create a user for WordPress:

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';

Next, grant all privileges to the WordPress user:

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';

Next, flush the privileges:

FLUSH PRIVILEGES;

Next, exit the MySQL shell:

exit

Step 4 Configure WordPress

To configure WordPress, run the following command:

Terminal window
sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

Next, open the WordPress configuration file:

Terminal window
sudo vi /var/www/html/wordpress/wp-config.php

Next, update the database name, user, and password:

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** Database username */
define('DB_USER', 'wordpressuser');
/** Database password */
define('DB_PASSWORD', 'password');

Next, save and close the file.

Step 5 Set up WordPress

To set up WordPress, open your web browser and navigate to your domain name. For example, https://example.com.

Next, click on the Let’s go! button.

Next, enter the site title, username, password, and email address:

WordPress Site Title, Username, Password, and Email Address

Next, click on the Install WordPress button.

Next, click on the Log In button.

Next, enter the username and password:

WordPress Username and Password

Next, click on the Log In button.

Now, you have successfully installed WordPress on Amazon Linux 2.

WordPress Dashboard


Note

Remember to protect your WordPress Admin Panel and cover up the URL and WordPress version.

Conclusion

This covered installing WordPress on Amazon Linux 2 and configuring it to run with Apache, PHP, and MariaDB.

Resources

Was this useful?

You might also enjoy

More posts on similar topics

How to Install PHP and MariaDB on Amazon Linux 2

How to Install PHP and MariaDB on Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023 there is no ext

How to Install Apache Web Server on Amazon Linux 2

How to Install Apache Web Server on Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023 the same steps

How to Install and Setup FireWall on Amazon Linux 2

How to Install and Setup FireWall on Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. iptables/firewalld behave the sa

How To Create An AWS EC2 Instance Using AWS CLI

How To Create An AWS EC2 Instance Using AWS CLI

Introduction In this tutorial we will create an AWS EC2 instance with the AWS CLI. We will build the network around it first, then launch the instance with a user data script that installs the Apa

How to Install and Configure Node.js on EC2 Instance Amazon Linux 2

How to Install and Configure Node.js on EC2 Instance Amazon Linux 2

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023, install Node.j

How to Run an Apache Web Server Using Docker on an AWS EC2 Instance

How to Run an Apache Web Server Using Docker on an AWS EC2 Instance

Amazon Linux 2 reached its announced end-of-support date on 30 June 2026, so it is no longer the right base image for a new instance. On Amazon Linux 2023, `sudo amazon-l

6 related posts