Apache-2.2

在 CentOS 上安裝 mod_pagespeed(Apache 模組)

  • December 21, 2011

我有一個已安裝 Apache (2.2.3) 的 CentOS (5.7 Final) 系統。

我已按照以下說明安裝了 mod_pagespeed:http ://code.google.com/speed/page-speed/download.html並在安裝時獲得了以下資訊:

# rpm -U mod-pagespeed-*.rpm
warning: mod-pagespeed-beta_current_x86_64.rpm: Header V4 DSA signature: NOKEY, key ID 7fac5991
[  OK  ] atd: [  OK  ]

它似乎安裝正確:

# apachectl -t -D DUMP_MODULES
Loaded Modules:
...
pagespeed_module (shared)

我在 /etc/httpd/conf.d/pagespeed.conf 中做了以下更改

添加:

ModPagespeedEnableFilters collapse_whitespace,elide_attributes
ModPagespeedEnableFilters combine_css,rewrite_css,move_css_to_head,inline_css
ModPagespeedEnableFilters rewrite_javascript,inline_javascript
ModPagespeedEnableFilters rewrite_images,insert_img_dimensions
ModPagespeedEnableFilters extend_cache
ModPagespeedEnableFilters remove_quotes,remove_comments

ModPagespeedEnableFilters add_instrumentation

註釋掉 mod_pagespeed_statistics 中的以下行

<Location /mod_pagespeed_statistics>
   **# Order allow,deny**
   # You may insert other "Allow from" lines to add hosts you want to
   # allow to look at generated statistics.  Another possibility is
   # to comment out the "Order" and "Allow" options from the config
   # file, to allow any client that can reach your server to examine
   # statistics.  This might be appropriate in an experimental setup or
   # if the Apache server is protected by a reverse proxy that will
   # filter URLs in some fashion.
   **# Allow from localhost**
   **# Allow from 127.0.0.1**
   SetHandler mod_pagespeed_statistics
</Location>

作為單獨的說明,我正在嘗試按照Google網站上的規定執行規定的系統測試,但它給出了以下錯誤。我反對在我的伺服器上更新 wget,因為我確信實際模組不需要它來正常執行。

./system_test.sh www.domain.com
You have the wrong version of wget. 1.12 is required.

我在 CentOS 系統上安裝 mod_pagespeed 時遇到了一個問題,它在安裝後拒絕工作。

事實證明,特定文件夾存在權限/所有權訪問問題。

在 /var/www/ 中,存在:

drwxr-xr-x  4 root      root   4096 Dec  8 12:02 mod_pagespeed
drwxr-xr-x  2 root      root   4096 Dec  8 12:03 mod_pagespeedcache

我將權限更改為:

drwxr-xr-x  4 apache    apache 4096 Dec  8 12:02 mod_pagespeed
drwxr-xr-x  4 apache    apache 4096 Dec 10 13:10 mod_pagespeedcache

日誌顯示:

...
[Sat Dec 10 13:08:43 2011] [error] [mod_pagespeed 0.10.19.4-1209 @30739] /var/www/mod_pagespeedcache/XAM3DOzfwmGm-DkPVUC7.outputlock:0: creating dir (code=13 Permission denied)
...

之後工作正常。

引用自:https://serverfault.com/questions/334469