我有一个 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>
另外,我尝试按照 google 网站上的规定运行系统测试,但出现以下错误。我不愿意在我的服务器上更新 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)
...
此后工作正常。