-
-
Save nguyenbathanh/2ecdb6e07b86fc7ca634ec6725299101 to your computer and use it in GitHub Desktop.
Revisions
-
GAS85 revised this gist
Mar 11, 2020 . 1 changed file with 24 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ * Based on https://techwombat.com/enable-http2-apache-ubuntu-16-04/ * *This totorial is for an older Ubuntu **16.04**, for a Ubuntu **18.04** please read here* --> https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831 # Requirements @@ -12,9 +14,9 @@ Let’s assume you installed Apache from the standard stable Ubuntu repository u apache2 -v … You’ll notice that Apache **2.4.18** is the [current default version for Ubuntu 16.04](https://packages.ubuntu.com/xenial/web/apache2). However, you need Apache 2.4.24 or later for compatibility with HTTP/2. To get a newer version of Apache, you can use the PPA from [Ondřej Surý](https://launchpad.net/~ondrej) which includes the latest stable release (Apache 2.4.33 at time of writing). Ondřej is a prominent PHP developer in the Debian community, so this PPA is considered safe. To add the PPA, type: @@ -35,7 +37,22 @@ This will update and upgrade apache2 to Apache 2.4.33+. You want to make Apache use a compatible PHP implementation by changing mod_php to php-fpm (PHP FastCGI). If your website or app breaks on FastCGI, you can always revert back to mod_php until further troubleshooting. Install PHP FastCGI module for PHP 7.0 [current default version for Ubuntu 16.04](https://packages.ubuntu.com/xenial/php/php-fpm) <details> <summary>(replace with “7.4” if desired):</summary> ------ * Added Repo with latest PHP: ``` sudo add-apt-repository ppa:ondrej/php ``` * Then install it and follow instruction from below with respect of php 7.4 Version. ``` sudo apt update sudo apt install php7.4-fpm ``` ------ </details> sudo apt install php7.0-fpm @@ -51,9 +68,9 @@ _Disable_ the **mod_php** module: sudo a2dismod php7.0 Restart Apache if no errors comes: sudo service apache2 restart ## Step 3: Change MPM from "prefork" to "event" @@ -145,7 +162,7 @@ P.S. All in one command (you still have to edit your VirtualHost and ssl config) sudo service apache2 restart sudo a2dismod mpm_prefork sudo a2enmod mpm_event sudo service apache2 restart sudo service php7.0-fpm restart sudo a2enmod http2 sudo service apache2 restart -
GAS85 revised this gist
Mar 11, 2020 . 1 changed file with 14 additions and 13 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,9 @@ From https://techwombat.com/enable-http2-apache-ubuntu-16-04/ # Requirements * A self-managed VPS or dedicated server with Ubuntu 16.04 running Apache 2.4.xx. * For **Ubuntu 18.04** please read here --> https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831 * A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode. ## Step 1: Upgrade Apache from PPA @@ -50,9 +51,9 @@ _Disable_ the **mod_php** module: sudo a2dismod php7.0 Test configuration and restart Apache if no errors comes: sudo apachectl configtest && sudo service apache2 restart ## Step 3: Change MPM from "prefork" to "event" @@ -111,9 +112,9 @@ Enable the http2.conf by running sudo a2enconf http2 Test configuration and restart Apache if no errors comes: sudo apachectl configtest && sudo service apache2 restart and enhance your ssl-vhost file (default-ssl.conf): @@ -137,14 +138,14 @@ P.S. All in one command (you still have to edit your VirtualHost and ssl config) sudo add-apt-repository ppa:ondrej/apache2 sudo apt update sudo apt upgrade sudo apt install php7.0-fpm sudo a2enmod proxy_fcgi setenvif sudo a2enconf php7.0-fpm sudo a2dismod php7.0 sudo service apache2 restart sudo a2dismod mpm_prefork sudo a2enmod mpm_event sudo apachectl configtest && sudo service apache2 restart sudo service php7.0-fpm restart sudo a2enmod http2 sudo service apache2 restart @@ -153,4 +154,4 @@ P.S. All in one command (you still have to edit your VirtualHost and ssl config) sudo echo "H2Direct on" >> /etc/apache2/conf-available/http2.conf sudo echo "</IfModule>" >> /etc/apache2/conf-available/http2.conf sudo a2enconf http2 sudo apachectl configtest && sudo service apache2 restart -
GAS85 revised this gist
Dec 4, 2019 . 1 changed file with 5 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ from https://techwombat.com/enable-http2-apache-ubuntu-16-04/ # Requirements * A self-managed VPS or dedicated server with Ubuntu 16.04 running Apache 2.4.xx. Read for Ubuntu 18.04 --> https://gist.github.com/GAS85/8dadbcb3c9a7ecbcb6705530c1252831 * A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode. ## Step 1: Upgrade Apache from PPA @@ -34,7 +34,7 @@ This will update and upgrade apache2 to Apache 2.4.33+. You want to make Apache use a compatible PHP implementation by changing mod_php to php-fpm (PHP FastCGI). If your website or app breaks on FastCGI, you can always revert back to mod_php until further troubleshooting. Install PHP FastCGI module for PHP 7.0 (replace with “7.1” if desired): sudo apt install php7.0-fpm @@ -83,7 +83,8 @@ Add the following line to your site’s current Virtual Host config file. This c _Explanation_: h2 is TLS-encrypted HTTP/2, h2c is cleartext HTTP/2, and http/1.1 is ordinary HTTP/1.1. Having http/1.1 at the end of the line provides a fallback to HTTP/1.1, while h2c is not strictly necessary. ## Step 5: Enable the mod_http2 Apache module Now you can enable the http2 module in Apache: @@ -93,7 +94,7 @@ Restart Apache: sudo service apache2 restart ## Step 6 create http2.conf for entire Server HTTP2 Create a new http2.conf -
GAS85 revised this gist
Aug 19, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -132,6 +132,7 @@ Amend in your configuration file: ... P.S. All in one command (you still have to edit your VirtualHost and ssl config): sudo add-apt-repository ppa:ondrej/apache2 sudo apt update sudo apt upgrade -
GAS85 revised this gist
Aug 19, 2019 . 1 changed file with 24 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -112,11 +112,8 @@ Enable the http2.conf by running Restart your Apache2 sudo service apache2 restart and enhance your ssl-vhost file (default-ssl.conf): sudo nano /etc/apache2/sites-available/default-ssl.conf @@ -132,4 +129,26 @@ Amend in your configuration file: H2PushPriority image/jpeg after 32 H2PushPriority image/png after 32 H2PushPriority application/javascript interleaved ... P.S. All in one command (you still have to edit your VirtualHost and ssl config): sudo add-apt-repository ppa:ondrej/apache2 sudo apt update sudo apt upgrade sudo apt install php7.0-fpm sudo a2enmod proxy_fcgi setenvif sudo a2enconf php7.0-fpm sudo a2dismod php7.0 sudo service apache2 restart sudo a2dismod mpm_prefork sudo a2enmod mpm_event sudo service apache2 restart sudo service php7.0-fpm restart sudo a2enmod http2 sudo service apache2 restart sudo echo "<IfModule http2_module>" > /etc/apache2/conf-available/http2.conf sudo echo "Protocols h2 h2c http/1.1" >> /etc/apache2/conf-available/http2.conf sudo echo "H2Direct on" >> /etc/apache2/conf-available/http2.conf sudo echo "</IfModule>" >> /etc/apache2/conf-available/http2.conf sudo a2enconf http2 sudo service apache2 restart -
GAS85 revised this gist
Apr 20, 2018 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -121,17 +121,15 @@ and enhance your ssl-vhost file (default-ssl.conf): sudo nano /etc/apache2/sites-available/default-ssl.conf Amend in your configuration file: ... Protocols h2 h2c http/1.1 H2Push on H2PushPriority * after H2PushPriority text/css before H2PushPriority image/jpg after 32 H2PushPriority image/jpeg after 32 H2PushPriority image/png after 32 H2PushPriority application/javascript interleaved ... -
GAS85 created this gist
Apr 20, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,137 @@ from https://techwombat.com/enable-http2-apache-ubuntu-16-04/ # Requirements * A self-managed VPS or dedicated server with Ubuntu 16.04 running Apache 2.4.xx. * A registered domain name with working HTTPS (TLS/SSL). HTTP/2 only works alongside HTTPS because most browsers, including Firefox and Chrome, don’t support HTTP/2 in cleartext (non-TLS) mode. ## Step 1: Upgrade Apache from PPA Let’s assume you installed Apache from the standard stable Ubuntu repository using apt. When you check your version of apache2 by typing: apache2 -v … You’ll notice that Apache **2.4.18** is the current default version for Ubuntu 16.04. However, you need Apache 2.4.24 or later for compatibility with HTTP/2. To get a newer version of Apache, you can use the PPA from Ondřej Surý which includes the latest stable release (Apache 2.4.33 at time of writing). Ondřej is a prominent PHP developer in the Debian community, so this PPA is considered safe. To add the PPA, type: sudo add-apt-repository ppa:ondrej/apache2 Or, you can add the PPA manually by inserting these lines into /etc/apt/sources.list: deb http://ppa.launchpad.net/ondrej/apache2/ubuntu xenial main deb-src http://ppa.launchpad.net/ondrej/apache2/ubuntu xenial main Once the PPA is added, update and upgrade Apache: sudo apt update sudo apt upgrade This will update and upgrade apache2 to Apache 2.4.33+. ## Step 2: Tell Apache to use PHP FastCGI You want to make Apache use a compatible PHP implementation by changing mod_php to php-fpm (PHP FastCGI). If your website or app breaks on FastCGI, you can always revert back to mod_php until further troubleshooting. # Install PHP FastCGI module for PHP 7.0 (replace with “7.1” if desired): sudo apt install php7.0-fpm Enable required modules, **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 Apache: sudo service apache2 restart ## Step 3: Change MPM from "prefork" to "event" Since the default "prefork" MPM (Multi-Processing Module) is not fully compatible with HTTP/2, you’ll need to change Apache’s current MPM to "event" (or "worker"). This is shown by the error message in Apache versions greater than 2.4.27 as – AH10034: The mpm module (prefork.c) is not supported by mod_http2. Keep in mind that your server requires more horsepower for HTTP/2 than for HTTP/1.1, due to the multiplexing feature and other factors. That said, smaller servers with low traffic may not see much difference in performance. First, disable the "prefork" MPM: sudo a2dismod mpm_prefork Enable the "event" MPM: sudo a2enmod mpm_event Restart Apache and PHP 7.0: sudo service apache2 restart sudo service php7.0-fpm restart ## Step 4: Add a line to your Virtual Host file Add the following line to your site’s current Virtual Host config file. This can go anywhere between the <VirtualHost>...</VirtualHost> tags. If you want to serve HTTP/2 for all your sites, add this to your global /etc/apache2/apache2.conf file instead of per each individual site’s Virtual Host file. Protocols h2 h2c http/1.1 _Explanation_: h2 is TLS-encrypted HTTP/2, h2c is cleartext HTTP/2, and http/1.1 is ordinary HTTP/1.1. Having http/1.1 at the end of the line provides a fallback to HTTP/1.1, while h2c is not strictly necessary. Step 5: Enable the mod_http2 Apache module Now you can enable the http2 module in Apache: sudo a2enmod http2 Restart Apache: sudo service apache2 restart ## Step 5 create http2.conf for entire Server HTTP2 Create a new http2.conf sudo nano /etc/apache2/conf-available/http2.conf and add all the following rows: <IfModule http2_module> Protocols h2 h2c http/1.1 H2Direct on </IfModule> Enable the http2.conf by running sudo a2enconf http2 Restart your Apache2 service apache2 restart and enhance your ssl-vhost file (default-ssl.conf): sudo nano /etc/apache2/sites-available/default-ssl.conf Amend the red ones in your configuration file: ... SSLEngine on (🍎)Protocols h2 h2c http/1.1 H2Push on H2PushPriority * after H2PushPriority text/css before H2PushPriority image/jpg after 32 H2PushPriority image/jpeg after 32 H2PushPriority image/png after 32 H2PushPriority application/javascript interleaved SSLOptions +StrictRequire ...