DEV Community

Cover image for How to Install WordPress on Amazon Linux 2
Mohammad Abu Mattar
Mohammad Abu Mattar

Posted on • Updated on

How to Install WordPress on Amazon Linux 2

Introduction

We will learn how to install WordPress on Amazon Linux 2 in this tutorial. We will also discover how to set up WordPress so that it functions with the Apache web server. We will also discover how to set up WordPress so that it functions with 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:

sudo wget https://wordpress.org/latest.tar.gz
Enter fullscreen mode Exit fullscreen mode

Step 2 — Extract WordPress

To extract the WordPress archive, run the following command:

sudo tar -xzvf latest.tar.gz
Enter fullscreen mode Exit fullscreen mode

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

sudo mv wordpress /var/www/html/
Enter fullscreen mode Exit fullscreen mode

Step 3 — Create a WordPress Database

To create a WordPress database, run the following command:

sudo mysql -u root -p
Enter fullscreen mode Exit fullscreen mode

Next, create a database for WordPress:

CREATE DATABASE wordpress;
Enter fullscreen mode Exit fullscreen mode

Next, create a user for WordPress:

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
Enter fullscreen mode Exit fullscreen mode

Next, grant all privileges to the WordPress user:

GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
Enter fullscreen mode Exit fullscreen mode

Next, flush the privileges:

FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

Next, exit the MySQL shell:

exit
Enter fullscreen mode Exit fullscreen mode

Step 4 — Configure WordPress

To configure WordPress, run the following command:

sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
Enter fullscreen mode Exit fullscreen mode

Next, open the WordPress configuration file:

sudo vi /var/www/html/wordpress/wp-config.php
Enter fullscreen mode Exit fullscreen mode

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');
Enter fullscreen mode Exit fullscreen mode

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

In this tutorial, we learned how to install WordPress on Amazon Linux 2. We also discovered how to set up WordPress so that it functions with the Apache web server. We also discovered how to set up WordPress so that it functions with PHP and MariaDB.

Resources

Top comments (2)

Collapse
 
abdrehman98 profile image
Abdul Rehman

Hi @mkabumattar,

Links in prerequisites are not working.

Collapse
 
mkabumattar profile image
Mohammad Abu Mattar

Hi @abdrehman98,

Thank you for bringing this to my attention. The post is now updated.