---
title: "How to Install WordPress on Amazon Linux 2"
lang: "en"
author: "Mohammad Abu Mattar"
canonical: https://mkabumattar.com/post/how-to-install-wordpress-on-amazon-linux-2
---

![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.](/_astro/hero.CFnKBY7F_1z2kcz.webp)

[Home](/)›[Blog](/blog)›[All Categories](/blog/categories)›[AWS](/blog/categories/aws)

Blog

[Prev in AWSHow to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)[Next in AWSHow to Run an Apache Web Server Using Docker on an AWS EC2 Instance](/blog/post/how-to-run-an-apache-web-server-using-docker-on-an-aws-ec2-instance)

[AWS](/blog/categories/aws)[EC2](/blog/categories/ec2)[WordPress](/blog/categories/wordpress)[LAMP Stack](/blog/categories/lamp-stack)[Linux](/blog/categories/linux)

# How to Install WordPress on Amazon Linux 2

[Mohammad Abu Mattar](/authors/mohammad-abu-mattar)Published: 24 Oct 202202 Mins read04 Mins listen

[Markdown for AI(opens in a new tab)](/post/how-to-install-wordpress-on-amazon-linux-2/index.md "Open the plain-Markdown version of this page, for pasting into an AI tool")

TL;DR

How to install WordPress on Amazon Linux 2 and configure it to run with Apache, PHP, and MariaDB.

Series

[Amazon Linux 2 LAMP Stack Setup](/series/amazon-linux-2-lamp-stack-setup)4/4

[PreviousHow to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

All posts in this series (4)

Blog4

1.  [How to Install and Setup FireWall on Amazon Linux 2](/blog/post/how-to-install-and-setup-firewall-on-amazon-linux-2)
2.  [How to Install Apache Web Server on Amazon Linux 2](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)
3.  [How to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)
4.  [How to Install WordPress on Amazon Linux 2You are here](/blog/post/how-to-install-wordpress-on-amazon-linux-2)

### How to Install WordPress on Amazon Linux 2

Contents

[Introduction](#introduction)[Prerequisites](#prerequisites)[Installing WordPress, setting up WordPress, and running a basic WordPress demo](#installing-wordpress-setting-up-wordpress-and-running-a-basic-wordpress-demo)[Step 1 Download WordPress](#step-1-download-wordpress)[Step 2 Extract WordPress](#step-2-extract-wordpress)[Step 3 Create a WordPress database](#step-3-create-a-wordpress-database)[Step 4 Configure WordPress](#step-4-configure-wordpress)[Step 5 Set up WordPress](#step-5-set-up-wordpress)[Conclusion](#conclusion)[Resources](#resources)

## [Introduction](#introduction)

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

## [Prerequisites](#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](#installing-wordpress-setting-up-wordpress-and-running-a-basic-wordpress-demo)

### [Step 1 Download WordPress](#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

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

### [Step 2 Extract WordPress](#step-2-extract-wordpress)

To extract the WordPress archive, run the following command:

Terminal window

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

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

Terminal window

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

### [Step 3 Create a WordPress database](#step-3-create-a-wordpress-database)

To create a WordPress database, run the following command:

Terminal window

```
1sudo mysql -u root -p
```

Next, create a database for WordPress:

```
1CREATE DATABASE wordpress;
```

Next, create a user for WordPress:

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

Next, grant all privileges to the WordPress user:

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

Next, flush the privileges:

```
1FLUSH PRIVILEGES;
```

Next, exit the MySQL shell:

```
1exit
```

### [Step 4 Configure WordPress](#step-4-configure-wordpress)

To configure WordPress, run the following command:

Terminal window

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

Next, open the WordPress configuration file:

Terminal window

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

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

```
1/** The name of the database for WordPress */2define('DB_NAME', 'wordpress');3/** Database username */4define('DB_USER', 'wordpressuser');5/** Database password */6define('DB_PASSWORD', 'password');
```

Next, save and close the file.

### [Step 5 Set up WordPress](#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)

  

Note

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

## [Conclusion](#conclusion)

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

## [Resources](#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)

Was this useful?

## Tags

[#WordPress Installation](/blog/tags/wordpress-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#Apache Setup](/blog/tags/apache-setup)[#PHP Configuration](/blog/tags/php-configuration)[#MariaDB Setup](/blog/tags/mariadb-setup)[#LAMP](/blog/tags/lamp)[#CMS](/blog/tags/cms)[#Web Hosting](/blog/tags/web-hosting)

## Share

[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2 "Share on Facebook")[Twitter](https://twitter.com/intent/tweet/?text=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2 "Share on Twitter")[LinkedIn](https://www.linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2&title=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202&summary=How%20to%20install%20WordPress%20on%20Amazon%20Linux%202%20and%20configure%20it%20to%20run%20with%20Apache%2C%20PHP%2C%20and%20MariaDB.&source=https://mkabumattar.com "Share on LinkedIn")[WhatsApp](https://wa.me/?text=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202%20https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2 "Share on WhatsApp")[Telegram](https://t.me/share/url?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2&text=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202 "Share on Telegram")[Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2&title=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202 "Share on Reddit")[Hacker News](http://news.ycombinator.com/submitlink?u=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2&t=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202 "Share on Hacker News")[Pinterest](https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2&media=&description=How%20to%20install%20WordPress%20on%20Amazon%20Linux%202%20and%20configure%20it%20to%20run%20with%20Apache%2C%20PHP%2C%20and%20MariaDB. "Share on Pinterest")[Email](<mailto:?subject=How%20to%20Install%20WordPress%20on%20Amazon%20Linux%202&body=Check out this article: https%3A%2F%2Fmkabumattar.com%2Fblog%2Fpost%2Fhow-to-install-wordpress-on-amazon-linux-2>)

## Comments

## You might also enjoy

More posts on similar topics

[![How to Install PHP and MariaDB on Amazon Linux 2](/_astro/hero.BxVn8-Uf_Z1fCiGj.webp)](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

## [How to Install PHP and MariaDB on Amazon Linux 2](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [PHP](/blog/categories/php)
-   [MariaDB](/blog/categories/mariadb)
-   [Apache](/blog/categories/apache)
-   [LAMP Stack](/blog/categories/lamp-stack)
-   [Linux](/blog/categories/linux)

Introduction In this tutorial we will set up PHP and MariaDB on Amazon Linux 2. We will get PHP working with the Apache web server, secure the MariaDB install, and then connect the two with a smal

[#PHP Installation](/blog/tags/php-installation)[#MariaDB Installation](/blog/tags/mariadb-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)+5 tags

[read more](/blog/post/how-to-install-php-and-mariadb-on-amazon-linux-2)

[![How to Install Apache Web Server on Amazon Linux 2](/_astro/hero.CFurz9Hr_Z2mT9lT.webp)](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

## [How to Install Apache Web Server on Amazon Linux 2](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Apache](/blog/categories/apache)
-   [Web Server](/blog/categories/web-server)
-   [Linux](/blog/categories/linux)
-   [Firewall](/blog/categories/firewall)

Introduction In this tutorial, we will learn how to install Apache web server on Amazon Linux 2. We will also learn how to configure Apache web server to serve a simple HTML web page. Prerequi

[#Apache Installation](/blog/tags/apache-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#HTTPD](/blog/tags/httpd)+4 tags

[read more](/blog/post/how-to-install-apache-web-server-on-amazon-linux-2)

[![How to Install and Setup FireWall on Amazon Linux 2](/_astro/hero.b8oDtFR4_ZdWcUP.webp)](/blog/post/how-to-install-and-setup-firewall-on-amazon-linux-2)

## [How to Install and Setup FireWall on Amazon Linux 2](/blog/post/how-to-install-and-setup-firewall-on-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Linux](/blog/categories/linux)
-   [Firewall](/blog/categories/firewall)
-   [Security](/blog/categories/security)

Introduction This tutorial covers installing and configuring firewalld on Amazon Linux 2, including setting the default zone and managing services and ports. Prerequisites To follow along wit

[#Firewalld](/blog/tags/firewalld)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#EC2 Security](/blog/tags/ec2-security)+5 tags

[read more](/blog/post/how-to-install-and-setup-firewall-on-amazon-linux-2)

[![How To Create An AWS EC2 Instance Using AWS CLI](/_astro/hero.Dh2x9Phr_14dc4A.webp)](/blog/post/how-to-create-an-aws-ec2-instance-using-aws-cli)

## [How To Create An AWS EC2 Instance Using AWS CLI](/blog/post/how-to-create-an-aws-ec2-instance-using-aws-cli)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [VPC](/blog/categories/vpc)
-   [AWS CLI](/blog/categories/aws-cli)
-   [WordPress](/blog/categories/wordpress)
-   [Linux](/blog/categories/linux)

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

[#AWS CLI EC2](/blog/tags/aws-cli-ec2)[#AWS CLI VPC](/blog/tags/aws-cli-vpc)[#VPC Configuration](/blog/tags/vpc-configuration)+8 tags

[read more](/blog/post/how-to-create-an-aws-ec2-instance-using-aws-cli)

[![How to Install and Configure Node.js on EC2 Instance Amazon Linux 2](/_astro/hero.CIYv_zEL_2aFueX.webp)](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

## [How to Install and Configure Node.js on EC2 Instance Amazon Linux 2](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Node.js](/blog/categories/nodejs)
-   [Linux](/blog/categories/linux)

Introduction Node.js does not exist in the default Amazon Linux 2 repository. So, we need to add the Node.js repository to the system. In this post, we will learn how to install and configure Node

[#Node.js Installation](/blog/tags/nodejs-installation)[#Amazon Linux 2](/blog/tags/amazon-linux-2)[#AWS EC2 Setup](/blog/tags/aws-ec2-setup)+3 tags

[read more](/blog/post/how-to-install-and-configure-nodejs-on-ec2-instance-amazon-linux-2)

[![How to Run an Apache Web Server Using Docker on an AWS EC2 Instance](/_astro/hero.WA3H4xsW_KuMrf.webp)](/blog/post/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](/blog/post/how-to-run-an-apache-web-server-using-docker-on-an-aws-ec2-instance)

-   [Mohammad Abu Mattar](/authors/mohammad-abu-mattar)
-   [AWS](/blog/categories/aws)
-   [EC2](/blog/categories/ec2)
-   [Docker](/blog/categories/docker)
-   [Apache](/blog/categories/apache)
-   [Web Server](/blog/categories/web-server)

Introduction In this post, we will learn how to run an Apache web server using Docker on an AWS EC2 instance. We will use the following tools:AWS EC2 \[Docker\](

[#AWS EC2 Docker](/blog/tags/aws-ec2-docker)[#Apache Docker](/blog/tags/apache-docker)[#Containerization](/blog/tags/containerization)+4 tags

[read more](/blog/post/how-to-run-an-apache-web-server-using-docker-on-an-aws-ec2-instance)

6 related posts
