我正在使用xampp sever最新版本来提高我的网页性能。
我必须在XAMPP中启用Gzip。 如何做呢?
你可以通过在apache中设置适当的指令来进行压缩。
它取消注释您的apache conf文件中的以下行:C:\ xampp \ apache \ conf \ httpd.conf
如果你的xampp安装文件夹是C:\ xampp。
而这些是首先要注意的行:
Loadmodulee headers_module modules/mod_deflate.so Loadmodulee filter_module modules/mod_filter.so
也就是说,如果他们之前有#,你应该删除他们!
然后把它放在你的httpd.conf文件的末尾:
SetOutputFilter DEFLATE <Directory "C:/your-server-root/manual"> #any path to which you wish to apply gzip compression to! <Ifmodulee mod_deflate.c> AddOutputFilterByType DEFLATE text/html # or any file type you wish </Ifmodulee> </Directory>
上面所说的一切都不能用在我的XAMPP版本1.8.1(php 5.4.7)上。
唯一可行的是把“开”,而不是“关”这些php.ini文件的这一行:
zlib.output_compression = On
找到apache \ conf \ httpd.conf
取消注释以下行(删除#)
Loadmodulee headers_module modules/mod_deflate.so
有些版本可能会要求您将下列行注释掉。
Loadmodulee headers_module modules/mod_headers.so Loadmodulee deflate_module modules/mod_deflate.so
最后把这一行添加到你的.htaccess文件中。
SetOutputFilter DEFLATE
不知道为什么你有这个代码:
Loadmodulee headers_module modules/mod_deflate.so
但是这并不适用于我,它在Apache / 2.4.3(Win32)上返回一个APACHE错误:
12:57:10 [Apache] Error: Apache shutdown unexpectedly. 12:57:10 [Apache] This may be due to a blocked port, missing dependencies, 12:57:10 [Apache] improper privileges, a crash, or a shutdown by another method.
我不得不使用:
Loadmodulee deflate_module modules/mod_deflate.so
有什么可以解决在XAMPP做到这一点。 我厌倦了在httpd.conf中添加下面的代码并重启apache,但是apache没有重启; 这是因为在文件中错过配置。
SetOutputFilter DEFLATE <Directory "C:/your-server-root/manual"> #any path to which you wish to apply gzip compression to! AddOutputFilterByType DEFLATE text/html # or any file type you wish </Directory>