Enabling HTTP/2 on your WordPress website hosted on an Apache server brings numerous performance benefits. This guide will walk you through the steps to enable HTTP/2 on your WordPress website hosted on an Apache server.
Prerequisites of Enabling HTTP/2 WordPress Apache
- Root access to your Apache server
- Basic understanding of Apache configuration files
- A running WordPress website
Step 1: Verify Current HTTP Version
Before making any changes, it’s a good idea to check if your website already supports HTTP/2. Use the KeyCDN HTTP/2 Test tool to verify.
Step 2: Locate Apache Configuration File
SSH into your server and navigate to your Apache
sites-available directory, usually located at
/etc/apache2/sites-available/. Assuming that you already have a valid SSL certificate, look for the SSL-enabled configuration file for your WordPress website, which often ends in
Step 3: Edit Apache Configuration File
Open the configuration file using a text editor like
sudo nano your-site-le-ssl.conf
Add the following line inside the
<VirtualHost *:443> block:
Protocols h2 http/1.1
Save and exit the editor.
Step 4: Check Loaded Apache Modules
Run the following command to see a list of loaded Apache modules:
http2_module is in the list. If not, you’ll need to enable it.
Step 5: Switch to Compatible MPM Module
HTTP/2 is not compatible with Apache’s
mpm_prefork module. You need to switch to a compatible MPM module like
sudo a2dismod mpm_prefork
sudo a2enmod mpm_event
Step 6: Configure PHP to Work with New MPM Module
First, find out which PHP version you are running with:
This will show you the version you have installed (e.g., PHP 7.4.10 or PHP 8.0.3).
If you are using PHP 7.4:
Disable the PHP 7.4 module:
sudo a2dismod php7.4
Enable PHP 7.4 FPM:
sudo a2enconf php7.4-fpm
If you are using PHP 8.0:
Disable the PHP 8.0 module:
sudo a2dismod php8.0
Enable PHP 8.0 FPM:
sudo a2enconf php8.0-fpm
Step 7: Restart Apache
Restart your Apache server to apply the changes:
sudo systemctl restart apache2
Step 8: Verify HTTP/2 WordPress Apache Support
Use the KeyCDN HTTP/2 Test tool again to confirm that your website now supports HTTP/2.
And there you have it! You’ve successfully enabled HTTP/2 for your WordPress site on Apache. This should help improve the loading speed and overall performance of your website.
I also have an article about how to Troubleshoot Common WordPress issues. Check it out!
If you encounter any challenges with your Apache or HTTP/2 configurations, feel free to leave a comment below. I’ll do my best to assist you in resolving any issues.