跳到主要內容

讓 Ubuntu 的Apache 支援 HTTP/2 的方法

網路上找到的方法如下:


  1. sudo -i
  2. apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
  3. reboot



  1. sudo -i
  2. apt-get install python-software-properties
  3. add-apt-repository -y ppa:ondrej/apache2
  4. add-apt-repository -y ppa:ondrej/php5
  5. apt-key update
  6. apt-get update && apt-get upgrade -y
  7. apt-get install -y php5-fpm apache2
  8. a2enmod proxy_fcgi proxy proxy_http http2 ssl expires headers rewrite



Change php5-fpm config to use TCP connection instead of socket.

sudo sed -i "s/listen =.*/listen = 127.0.0.1:9000/" /etc/php5/fpm/pool.d/www.conf

Open and edit the default HTTP virtual host.

nano /etc/apache2/sites-enabled/000-default.conf

Add these lines to the default HTTP virtual host config file, this assumes you have your DocumentRoot set to /var/www/html, in an existing setup this could be different and would need to be modified.

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1


# for a https server
Protocols h2 http/1.1


Restart services for changes to Apache 2.4.18 and PHP 5.5.32 to take effect.

service apache2 restart
service php5-fpm restart

(optional) Install and configure PageSpeed Module.

cd /tmp
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_amd64.deb
dpkg -i mod-pagespeed-*.deb
nano /etc/apache2/mods-enabled/pagespeed.conf
service apache2 restart

(optional) Install other PHP extensions and software packages.

# redis
apt-get install -y redis-server php5-redis


# memcached
apt-get install -y php5-memcached memcached


# restart php
service php5-fpm restart

留言

這個網誌中的熱門文章

解決Apache 2.2, 關於HTTPS 之下使用PROXY 面對的 proxy server received an invalid response from an upstream server 以及 proxy: pass request body failed 的問題

修改以下 (proxy 以及 從proxy 接收的server): httpd.conf: ----------- 在 Include conf.d/*.conf 的前面加入以下: LimitRequestBody 2147483647  #2Gb Timeout 24000 ProxyTimeout 24000 ProxyBadHeader Ignore ssl.conf ---------- 在各個virtualhost 裡加入以下:     SSLEngine on     SSLProxyEngine on     SSLProxyVerify none     SSLProxyCheckPeerCN off     #SSLProxyCheckPeerName off     SSLProxyProtocol +SSLv3 +TLSv1 +TLSv1.1 +TLSv1.2 以下這個只在proxy server 裡的virtualhost 設定     ProxyPass / https://REMOTE_HOST:443/ retry=1 acquire=3000 timeout=3600 Keepalive=On 

解決CentOS 8 的 failed to set locale defaulting to c.utf-8 的問題

這原因是沒有安裝好支援的語言與字型, 特別是UTF8 並沒有被安裝到 因此使用以下指令確認 localedef -i en_US -f UTF-8 en_US.UTF-8 假如出現 "[error] character map file `UTF-8' not found: No such file or directory" 或者 [error] default character map file 'ANSI_X3.4-1968' not found : No such file or directory 那就安裝UTF8 吧 yum whatprovides "*/UTF-8.gz" 如果找到的話 "UTF-8.gz" 的話 yum install "*/UTF-8.gz" -y 再執行一次: localedef -i en_US -f UTF-8 en_US.UTF-8