Guide to deploy WordPress on Amazon EC2 instance running Amazon Linux 2023 (AL2023)
Overview
This article suggests how you can install WordPress on Amazon EC2 instances running Amazon Linux 2023 (AL2023), including steps to obtain and install HTTPS certificate.
WordPress requirements
WordPress requirements are
- PHP 7.4 or greater
- MySQL 8.0 or greater
- MariaDB 10.5 or greater
Hosting team recommendations for WordPress 6.8 are
- PHP: 8.2.x, 8.3.x
- MySQL: 8.0.x, 8.4.x
- MariaDB: 10.11.x, 11.4.x
PHP 8.4 and MariaDB 10.11 were added to AL2023 versions 2023.7.20250331 and 2023.7.20250428 respectively.
Other supported PHP, MySQL and MariaDB versions are listed on WordPress Compatibility page.
Method 1: Manual Installation
Launch EC2 instance
Launch a new AL2023 EC2 instance with the following features
- Outbound internet connectivity
- Attached security group allows inbound HTTP and HTTPS
- Amazon Linux 2023 version 2023.7.20250428 or higher. To verify release version, execute
rpm -q system-release
. If you are running a lower version, refer to documentation for upgrade instructions
- To prevent your EC2 public IP address from changing, associate an Elastic IP address
Both x86_64 and arm64 architectures are supported, with AWS Graviton processors usually providing better PHP performance
Connect to EC2 instance
Connect to your EC2 instance.
Install Apache web server
sudo dnf install -y httpd mod_ssl mod_fcgid
sudo systemctl enable --now httpd
Install PHP
We will install PHP 8.3. Modify phpVersion
value below if you want to install a different PHP version
phpVersion=php8.3
sudo dnf install -y $phpVersion $phpVersion-{cli,fpm,opcache}
sudo dnf install -y $phpVersion-mysqlnd
sudo dnf install -y $phpVersion-{gd,intl,zip,bcmath,soap}
Compile PHP extensions
Highly recommended PHP extensions such as igbinary and imagick need to be compiled
sudo dnf install -y php-devel php-pear gcc
sudo pecl update-channels
cd /tmp
sudo pecl install igbinary
sudo tee /etc/php.d/25-igbinary.ini > /dev/null << EOF
extension=igbinary.so
EOF
sudo dnf install -y ImageMagick ImageMagick-devel
yes | sudo pecl install imagick
sudo tee /etc/php.d/25-imagick.ini > /dev/null << EOF
extension=imagick.so
EOF
sudo systemctl enable --now php-fpm
WordPress Hosting Handbook provides a complete list of recommended and optional extensions to install.
For example, you may want to compile apcu, redis and memcache recommended extensions. You can refer to How do I compile PHP extensions on Amazon Linux 2023? for PHP extension compilation guidance.
Install MariaDB database server
sudo dnf install -y mariadb1011-server
sudo systemctl enable --now mariadb
Create database and user
We will need to create a database and user. Modify below values especially DB_USER_PW
and execute the script block
DB=wordpress
DB_USER=wordpress
DB_USER_PW=changeStr@ongPass0rd
sudo mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_USER_PW';
CREATE DATABASE $DB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON $DB.* TO '$DB_USER'@'localhost';
FLUSH PRIVILEGES;"
Download WordPress installation files
Download latest WordPress version. If you need an earlier version, get download link from Releases page.
cd /tmp
curl -L -O https://wordpress.org/latest.tar.gz
tar -xf latest.tar.gz
sudo rsync -r /tmp/wordpress/ /var/www/html/
sudo chown apache:apache -R /var/www/html
Restart services
sudo systemctl restart php-fpm
sudo systemctl restart httpd
Install HTTPS certificate
This section requires a FQDN (fully qualified domain name) whose DNS entry resolves to your EC2 instance public internet IP address.
Skip this section if you do not have a domain name. Alternatively, go to Amazon Route 53 console to register a domain. After which, create a DNS record to your EC2 instance public IP address.
Using Certbot
While there are other options, this section shows how to use Certbot to request and install free HTTPS certificates.
Install Certbot and configure Apache virtual host.
sudo dnf install -y certbot python3-certbot-dns-route53 python3-certbot-apache
sudo systemctl daemon-reload
sudo systemctl enable --now certbot-renew.timer
sudo tee /etc/httpd/conf.d/www.conf > /dev/null << EOF
<VirtualHost *:80>
DocumentRoot /var/www/html
</VirtualHost>
EOF
sudo systemctl restart httpd
To obtain and install Let's Encrypt certificate for HTTPS
sudo certbot --apache
Refer to How to use Certbot to enable HTTPS with Apache or Nginx on EC2 instances running Amazon Linux 2023 (AL2023) ? for more details
WordPress installation
If you have installed a certificate, open a browser to your domain name, e.g. https://<wordpress.example.com>/
.
Else open a browser to your EC2 instance IP address, eg https://<EC2-IP-ADDRESS>

Run the install script. You will need to enter the database credentials that was configured previously to setup configuration file.
Optional: remote graphical desktop (GUI) access
If you need a graphical desktop environment, refer to How do I install GUI (graphical desktop) on Amazon EC2 instances running Amazon Linux 2023 (AL2023)?
Method 2: CloudFormation
This method uses CloudFormation infrastructure as code template to automate previous method install steps, and include additional functional, security and performance features.
Go to ec2-lamp-server GitHub repository and download AL2023 template.
Login to CloudFormation console and create a stack using the downloaded file.
In LAMP section, select WordPress
under Application stack to install

Refer to site for parameter options and deployment instructions, including WordPress install video and HTTPS certificate request.
Other Options
Other install options include:
Pre-built AMIs are available from AWS Marketplace