我试图限制自己在Stack Overflow上提出太多问题,但我一直试图在我的Apache2服务器上启用mod_pagespeed几天,并准备开始拔出我的头发了。我安装了mod_pagespeed和mod_pagespeed_ap24,虽然我的Apache2版本只需要mod_pagespeed_ap24。我在/apache2/conf/httpd.conf中编辑了Apache的配置,加载了
中的模块LoadModule pagespeed_module modules/mod_pagespeed_ap24.so
我成功重新启动了服务器,但获得了一个502错误的网关,而且这个错误
[mod_pagespeed 1.12.34.2-0 @27107] mod_pagespeed is enabled. FileCachePath must not be empty: define_name=(null) defne_line_number=0 server_hostname=web551.webfaction.com port=0
我多次尝试在linux中编辑mod_pagespeed的配置文件,但没有任何效果。所以我在Webfaction上创建了一个静态/ php / cgi的符号链接,通过Apache服务器而不是他们的nginix服务器来提供我的媒体,所以我可以使用.htaccess文件来配置我的Apache服务器。然而,我仍然遇到了这个问题。
.htaccess文件
Options +FollowSymLinks
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
#Begin gzip and deflate
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/css application/x-javascript text/plain text/xml image/x-icon
</IfModule>
<IfModule mod_pagespeed_ap24.c>
ModPagespeed on
ModPagespeedFileCachePath "/home/doc4design/var/cache/mod_pagespeed"
ModPagespeedEnableFilters rewrite_css,combine_css
ModPagespeedEnableFilters recompress_images
ModPagespeedEnableFilters convert_png_to_jpeg,convert_jpeg_to_webp
ModPagespeedEnableFilters collapse_whitespace,remove_comments
</IfModule>
Apache httpd.conf
ServerRoot "/home/doc4design/webapps/django_2016/apache2"
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule wsgi_module modules/mod_wsgi.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule pagespeed_module modules/mod_pagespeed_ap24.so
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog /home/doc4design/logs/user/access_django_2016.log combined
ErrorLog /home/doc4design/logs/user/error_django_2016.log
Listen 30651
KeepAlive Off
SetEnvIf X-Forwarded-SSL on HTTPS=1
ServerLimit 1
StartServers 1
MaxRequestWorkers 5
MinSpareThreads 1
MaxSpareThreads 3
ThreadsPerChild 5
WSGIDaemonProcess django_2016 processes=2 threads=12 maximum-requests=100 python-path=/home/doc4design/webapps/django_2016:/home/doc4design/webapps/django_2016/doc4_2016:/home/doc4design/webapps/django_2$
WSGIProcessGroup django_2016
WSGIRestrictEmbedded On
WSGILazyInitialization On
WSGIScriptAlias / /home/doc4design/webapps/django_2016/doc4_2016/webapp/wsgi.py
答案 0 :(得分:2)
您确定路径/home/doc4design/var/cache/mod_pagespeed
是否存在?如果是这样,Apache可以访问路径吗?
确认路径存在并向其上的www-data
授予权限,或者在其下运行用户apache的权限。