• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Fix HTTP/2 NOT Working on Apache 2.4 Running WordPress

By Abhishek Ghosh September 9, 2020 9:55 am Updated on September 9, 2020

Fix HTTP/2 NOT Working on Apache 2.4 Running WordPress

Advertisement

If you have followed older guides to configure the server to install WordPress, then you have followed the guides to install Mod PHP with MPM prefork. presently, the usual mod_php and prefork MPM module of Apache2 does not work with HTTP/2 module. The default prefork MPM is not fully compatible with HTTP/2. If you are running Apache alongside the mod_php module, you need to switch to PHP-FPM. You need to uninstall the prefork MPM and switch to the mpm_event module which will be supported by HTTP/2. Apache2 is always easy. All you have to do is running some commands to do the things we mentioned above and remember what you have done. In case you want to switch back to mod_php with MPM prefork, that is just easy. In short – if you are following this guide then bookmark it.

 

How to Enable HTTP/2 on Apache 2.4 for PHP/WordPress

 

If you are not using the PPA from Ondřej Surý then do these steps :

Vim
1
2
3
sudo add-apt-repository ppa:ondrej/apache2
sudo apt update
sudo apt upgrade

We are writing the commands for PHP 7.0, you can modify and use it for PHP 7.1, PHP 7.2, PHP 7.3, PHP 7.4 and so on. We are changing mod_php to php-fpm (PHP FastCGI). The setup will be somewhat like Nginx – you have to manually restart PHP-FPM and Apache2 for many settings to work.

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sudo apt install php7.0-fpm
# Enable proxy_fcgi and setenvif
sudo a2enmod proxy_fcgi setenvif
# Enable php7.0-fpm
sudo a2enconf php7.0-fpm
# Disable the mod_php module
sudo a2dismod php7.0
# Restart Apache2
sudo service apache2 restart
# Disable the "prefork" MPM
sudo a2dismod mpm_prefork
# Enable the "event" MPM
sudo a2enmod mpm_event
# Restart the services
sudo service apache2 restart
sudo service php7.0-fpm restart
# Enable HTTP/2 module
sudo a2enmod http2
# Restart Apache2
sudo service apache2 restart

 

Basic optimization

 

Inside the /etc/apache2/mods-enabled/ directory, you’ll get the configuration files for mpm_event, http2 etc.

Vim
1
2
cd /etc/apache2/mods-enabled/
ls

You can open the file and modify :

Vim
1
sudo nano /etc/apache2/mods-enabled/http2.conf

You can run a configtest :

Vim
1
2
3
sudo apachectl configtest
# and restart apache
sudo service apache2 restart

This is all default enabled http2.conf file :

Vim
1
2
3
4
5
6
7
8
9
10
11
<IfModule !mpm_prefork>
    Protocols h2 h2c http/1.1
    H2Direct on
    H2Push          on
    H2PushPriority * After 16
    H2PushPriority  *                       after
    H2PushPriority  text/css                before
    H2PushPriority  image/jpeg              after   32
    H2PushPriority  image/png               after   32
    H2PushPriority  application/javascript  interleaved
</IfModule>

Explanation is available on the official doc :

Vim
1
https://httpd.apache.org/docs/2.4/mod/mod_http2.html

Now open the mpm_event.conf file :

Vim
1
sudo nano /etc/apache2/mods-enabled/mpm_event.conf

This is optimized settings for a 16GB server :

Vim
1
2
3
4
5
6
7
8
9
10
<IfModule mpm_event_module>
        ServerLimit              2800
        StartServers             4
        MinSpareThreads          25
        MaxSpareThreads          75
        ThreadLimit              64
        ThreadsPerChild          25
        MaxRequestWorkers        2800
        MaxConnectionsPerChild   1000
</IfModule>

Now about PHP FPM (which is exactly like we do with Nginx) :

Vim
1
nano /etc/php/7.0/fpm/pool.d/www.conf

This should be enough for a 16GB server :

Vim
1
2
3
4
5
6
7
pm = dynamic
pm.max_children = 256
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 20
;pm.process_idle_timeout = 10s;
pm.max_requests = 1000

Restart the services:

Vim
1
2
sudo service php7.0-fpm restart
sudo service apache2 restart

Fix HTTP2 NOT Working on Apache 2-4 Running WordPress

 

How to revert back?

 

The easy way is to run the opposite commands, like a2dismod against previous a2enmod and vice-versa. However, it is practical to take a backup of all the configuration files of Apache, purge everything and freshly install Apache2 and PHP. Unlike Nginx, PHP-FPM does not hugely disturb with Apache.

Tagged With apache prefork http2
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Fix HTTP/2 NOT Working on Apache 2.4 Running WordPress

  • How to Install Apache MPM Event and PHP-FPM on Ubuntu Server

    If your production server is running Apache, mod_php and mpm prefork and you want to upgrade to MPM Event and PHP-FPM, then it is just a few steps. For this guide, we have tested the workflow on a server which is running PHP 7.2 (which is an old version). You can follow similar steps for […]

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS

    Here is Detailed Guide on How To Install Apache2 on Ubuntu 18.04 With Let’s Encrypt, HTTP/2, HSTS With Commands and Configurations For Most Secured Setup.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy