-
-
Save jasonsnider/762ab38b50177c3f8feaafe5526335fd to your computer and use it in GitHub Desktop.
Enable HTTP/2 on Ubuntu 20.04 with Apache2 and PHP7.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo a2enmod http2 | |
sudo a2dismod php7.4 | |
sudo a2dismod mpm_prefork | |
sudo a2enmod mpm_event proxy_fcgi setenvif | |
sudo apt install php7.4-fpm -y | |
sudo systemctl start php7.4-fpm | |
sudo systemctl enable php7.4-fpm | |
sudo a2enconf php7.4-fpm | |
sudo systemctl restart apache2 | |
sudo systemctl restart php7.4-fpm | |
echo "Add the following line to /etc/apache2/apache2.conf" | |
echo -e "\tProtocols h2 h2c http/1.1/n/n" | |
echo "vim /etc/apache2/apache2.conf" | |
echo -e "/n/nBe sure to mirror any php.ini settings such include_path, memory_limit, ect in /etc/php/7.4/fpm/php.ini/n/n" | |
echo "vim /etc/php/7.4/fpm/php.ini" |
Be sure to restart Apache after updating /etc/apache2/apache2.conf
sudo systemctl restart apache2
If you do not want to enable this globally you may add the following line to a target vhost file
Protocols h2 http/1.1
To run this as a shell do not forget to make it executable
chmod +x h2
./h2
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you need to update /etc/php/7.4/fpm/php.ini do not forget to restart the php7.4-fpm service.