Nginx 1.9 安裝 ngx_pagespeed 模組

來源:互聯網
上載者:User

Nginx 1.9 安裝 ngx_pagespeed 模組
1,關於pagespeed

ngx_pagespeed 是一個 Nginx 的擴充模組,可以加速你的網站,減少頁面載入時間,它會自動將一些提升web效能的實踐應用到網頁和相關的資源(CSS、JS和圖片)上,無需你修改內容和流程。

功能包括:
圖片最佳化: stripping meta-data, dynamic resizing, recompression
CSS & JavaScript 壓縮、合并等
小資源的內聯
延遲圖片和 JS 的載入
HTML 重寫
延長緩衝擴充

2,安裝

官方網站:
https://developers.google.com/speed/pagespeed/module/
有apache 和 nginx 的模組。
https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source
安裝指南。
apache 已經不用好多年,還是用nginx吧,我一般使用openresty的nginx。
http://openresty.org/

首先安裝依賴庫:

yum install gcc-c++ pcre-devel zlib-devel make unzip

下載好openresty的nginx(使用的是ngx_openresty-1.9.7.1),然後再上面在增加pagespeed 的模組
pagespeed使用的是 ngx_pagespeed-1.9.32.10-beta
:https://github.com/pagespeed/ngx_pagespeed/releases

openresy 1.9的版本已經支援http2的協議了。

./configure --prefix=/usr/local --with-luajit --with-http_stub_status_module --with-http_realip_module --with-http_v2_module --add-module=./ngx_pagespeed-1.9.32.10-beta

參數含義,指定安裝目錄,增加lua模組,stat統計,realip,http2支援和最後增加pagespeed模組。

在安裝之前需要下載 psol ,否則報錯

ngx_pagespeed: pagespeed optimization library not found: You need to separately download the pagespeed library: $ cd /path/to/ngx_pagespeed $ wget https://dl.google.com/dl/page-speed/psol/1.9.32.10.tar.gz $ tar -xzvf 1.9.32.10.tar.gz # expands to psol/ Or see the installation instructions: https://github.com/pagespeed/ngx_pagespeed#how-to-buildERROR: failed to run command: sh ./configure --prefix=/usr/local/openresty/nginx \...

下載psol,然後放到ngx_pagespeed 目錄下面就好了。

本文的原文串連是: http://blog.csdn.net/freewebsys/article/details/50479176 未經博主允許不得轉載。
博主地址是:http://blog.csdn.net/freewebsys

3,總結

pagespeed 模組能夠自動對js css html 進行壓縮,超級好用。
對頁面進行了最佳化,同時開啟了nginx的http2支援,越來越快了。
在用lua開發一些簡單攔截邏輯。目標是越來越快的。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.