Please enable JavaScript to view this site.
Steps for upgrading from HTTP/1 to HTTP/2 for an Apache/Ubuntu server:
There are many good articles on the advantages of HTTP/2 over HTTP/1 and the Apache event MPM over the prefork MPM. I am simply going to list the steps for performing the upgrade.
Notes: 1) These steps involve disabling the http/1 - prefork version of PHP. You should take down your site first to avoid displaying your PHP code to all your site visitors. 2) If you are using a different version of PHP than referenced below, change the line from php8.1 to phpx.x as needed.
Stop Apache:
Disable the http/1 - prefork version of PHP:
Disable the pre-fork module:
Enable PHP's event MPM module:
Install php-fpm:
Install the libapache2-mod-fcgid (FastCGI) library:
Perform the three following enabling commands:
Restart Apache:
If you had previously enabled html or other files to render php code, you will have to change the method. The examples below pertain to a site that enables html and shtml pages to parse php.
First, you must remove old code that will conflict with the event MPM. Remove or comment out the following line if it is in your apache2.conf or .htacces files.
Next, add the following code to one of the following three: apache2.conf, .htaccess file or apache2/sites-available config file.
SetHandler 'proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost'
Edit the following file:
Insert the following code into the www.conf file:
Mark sure the security.limit code does not have the
Reload php-fpm:
Enable http/2:
Insert the following code in your SSL config file: Protocols h2 http/1.1
In my case, the file is labeled:
It will look like this:
Protocols h2 http/1.1
Restart Apache:
Take steps to ensure that Apache does not automatically revert to the prefork mode by commenting out lines in the two following files.
Comment out the following line by using the
Comment out the following line by using the
There are many good articles on the advantages of HTTP/2 over HTTP/1 and the Apache event MPM over the prefork MPM. I am simply going to list the steps for performing the upgrade.
Notes: 1) These steps involve disabling the http/1 - prefork version of PHP. You should take down your site first to avoid displaying your PHP code to all your site visitors. 2) If you are using a different version of PHP than referenced below, change the line from php8.1 to phpx.x as needed.
Stop Apache:
sudo systemctl stop apache2
Disable the http/1 - prefork version of PHP:
sudo a2dismod php8.1
Disable the pre-fork module:
sudo a2dismod mpm_prefork
Enable PHP's event MPM module:
sudo a2enmod mpm_event
Install php-fpm:
sudo apt install php-fpm
Install the libapache2-mod-fcgid (FastCGI) library:
sudo apt install libapache2-mod-fcgid
Perform the three following enabling commands:
sudo a2enconf php8.1-fpm
sudo a2enmod proxy
sudo a2enmod proxy_fcgi
sudo a2enmod proxy
sudo a2enmod proxy_fcgi
Restart Apache:
sudo systemctl restart apache2
If you had previously enabled html or other files to render php code, you will have to change the method. The examples below pertain to a site that enables html and shtml pages to parse php.
First, you must remove old code that will conflict with the event MPM. Remove or comment out the following line if it is in your apache2.conf or .htacces files.
AddType application/x-httpd-php .html .shtml
Next, add the following code to one of the following three: apache2.conf, .htaccess file or apache2/sites-available config file.
Edit the following file:
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
Insert the following code into the www.conf file:
security.limit_extensions = .php .html .shtml
Mark sure the security.limit code does not have the
;in front of it.
Reload php-fpm:
sudo service php8.1-fpm reload
Enable http/2:
sudo a2enmod http2
Insert the following code in your SSL config file: Protocols h2 http/1.1
In my case, the file is labeled:
/etc/apache2/sites-enabled/webtracker.one-le-ssl.conf
It will look like this:
Restart Apache:
sudo systemctl restart apache2
Take steps to ensure that Apache does not automatically revert to the prefork mode by commenting out lines in the two following files.
sudo nano /etc/apache2/mods-available/mpm_prefork.load
Comment out the following line by using the
#symbol: #LoadModule mpm_prefork_module /usr/lib/apache2/modules/mod_mpm_prefork.so
sudo nano /etc/apache2/mods-available/mpm_worker.load
Comment out the following line by using the
#symbol: #LoadModule mpm_worker_module /usr/lib/apache2/modules/mod_mpm_worker.so
* posted by Robert on Tue, Aug 02, 2022
Site built and hosted by RJdesign.one