在 CentOS 上安裝 mod_pagespeed(Apache 模組)

在 CentOS 上安裝 mod_pagespeed(Apache 模組)

我有一個 CentOS (5.7 Final) 系統,上面已經安裝了 Apache (2.2.3)。

我已按照以下說明安裝了 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>

作為一個單獨的註釋,我試圖運行谷歌網站上指定的規定的系統測試,但它給出了以下錯誤。我不願意在我的伺服器上更新 wget,因為我確信實際模組不需要它才能正常運作。

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

答案1

我在 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)
...

之後工作得很好。

相關內容