---
title: "How to Install WordPress on Amazon Linux 2"
description: "How to install WordPress on Amazon Linux 2 and configure it to run with Apache, PHP, and MariaDB."
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/blog/post/how-to-install-wordpress-on-amazon-linux-2
---

# How to Install WordPress on Amazon Linux 2

## 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:

- An Amazon Linux 2 EC2 instance with a public IP address.
- A non-root user with sudo privileges.
- A domain name pointing to the public IP address of your EC2 instance.
- Apache web server installed and running. [How to Install Apache Web Server on Amazon Linux 2](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2).
- PHP installed and running. [How to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2).

## 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:

```shell
sudo wget https://wordpress.org/latest.tar.gz
```

### Step 2 Extract WordPress

To extract the WordPress archive, run the following command:

```shell
sudo tar -xzvf latest.tar.gz
```

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

```shell
sudo mv wordpress /var/www/html/
```

### Step 3 Create a WordPress database

To create a WordPress database, run the following command:

```shell
sudo mysql -u root -p
```

Next, create a database for WordPress:

```sql
CREATE DATABASE wordpress;
```

Next, create a user for WordPress:

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

Next, grant all privileges to the WordPress user:

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

Next, flush the privileges:

```sql
FLUSH PRIVILEGES;
```

Next, exit the MySQL shell:

```sql
exit
```

### Step 4 Configure WordPress

To configure WordPress, run the following command:

```shell
sudo cp /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php
```

Next, open the WordPress configuration file:

```shell
sudo vi /var/www/html/wordpress/wp-config.php
```

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

```php
/** 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](/assets/blog/0014-how-to-install-wordpress-on-amazon-linux-2/wordpress-site-title-username-password-and-email-address.png)

Next, click on the **Install WordPress** button.

Next, click on the **Log In** button.

Next, enter the username and password:

![WordPress Username and Password](/assets/blog/0014-how-to-install-wordpress-on-amazon-linux-2/wordpress-username-and-password.png)

Next, click on the **Log In** button.

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

![WordPress Dashboard](/assets/blog/0014-how-to-install-wordpress-on-amazon-linux-2/wordpress-dashboard.png)

<br />

  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

- [WordPress Official Website - Download](https://wordpress.org/download/)
- [WordPress Codex - Installing WordPress](https://wordpress.org/support/article/how-to-install-wordpress/)
- [WordPress Codex - Editing wp-config.php](https://wordpress.org/support/article/editing-wp-config-php/)
- [AWS Tutorial: Host a WordPress blog on Amazon Linux 2](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/hosting-wordpress.html)
- [Amazon EC2 User Guide for Linux Instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)
- [Apache HTTP Server Documentation](https://httpd.apache.org/docs/)
- [PHP Manual](https://www.php.net/manual/en/)
- [MariaDB Server Documentation](https://mariadb.com/kb/en/documentation/)
- [MySQL CREATE DATABASE Statement](https://dev.mysql.com/doc/refman/8.0/en/create-database.html) (MariaDB syntax is similar)
- [MySQL CREATE USER Statement](https://dev.mysql.com/doc/refman/8.0/en/create-user.html) (MariaDB syntax is similar)
- [MySQL GRANT Statement](https://dev.mysql.com/doc/refman/8.0/en/grant.html) (MariaDB syntax is similar)
- [Previous Post: How to Install Apache Web Server on Amazon Linux 2](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)
- [Previous Post: How to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)
- [wget Manual](https://www.gnu.org/software/wget/manual/wget.html)
- [tar Manual](https://www.gnu.org/software/tar/manual/tar.html)
