<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Eric&#039;s Who Know &#187; mod_deflate</title> <atom:link href="http://who-know.com/tag/mod_deflate/feed/" rel="self" type="application/rss+xml" /><link>http://who-know.com</link> <description>C&#039;est La Vie</description> <lastBuildDate>Mon, 17 May 2010 22:21:05 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>在虛擬主機有安裝 SuPHP 情況下啟用 Gzip</title><link>http://who-know.com/enable-gzip-compression-with-suphp-installed/</link> <comments>http://who-know.com/enable-gzip-compression-with-suphp-installed/#comments</comments> <pubDate>Tue, 15 Sep 2009 14:44:16 +0000</pubDate> <dc:creator>Eric</dc:creator> <category><![CDATA[Free Teaching]]></category> <category><![CDATA[.htaccess]]></category> <category><![CDATA[Gzip]]></category> <category><![CDATA[JustHost]]></category> <category><![CDATA[mod_deflate]]></category> <category><![CDATA[SuPHP]]></category><guid isPermaLink="false">http://who-know.com/?p=77</guid> <description><![CDATA[01. 因為希望 WordPress 可以再快一點, 所以就想把 Gzip 打開, 這就是成長的動力, 好還要更好, 沒有最好只有更好, 於是創了個 phpinfo.php, 想更進一步的來了解一下自己的虛擬主機。
&#60;?php phpinfo(); ?&#62;
查看了自己的 Server 是否有支援 GZIP, 發現恰是一切正常.HTTP_ACCEPT_ENCODING  gzip, deflate
_SERVER[&#34;HTTP_ACCEPT_ENCODING&#34;] gzip, deflate
_ENV[&#34;HTTP_ACCEPT_ENCODING&#34;] gzip, deflate02. 於是分別在 .htaccess file 加上
a. 結果出現 HTTP 500 - Internal Server Error.php_flag zlib.output_compression on
php_value zlib.output_compression_level 4b. 第二種沒反應  // that is, 不支持 mod_deflate&#60;ifmodule mod_deflate.c&#62;
DeflateCompressionLevel 4
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter [...]]]></description> <content:encoded><![CDATA[<p>01. 因為希望 <a href="http://wordpress.org/" target="_blank">WordPress</a> 可以再快一點, 所以就想把 Gzip 打開, 這就是成長的動力, 好還要更好, 沒有最好只有更好, 於是創了個 phpinfo.php, 想更進一步的來了解一下自己的虛擬主機。</p><pre class="brush: php;">&lt;?php phpinfo(); ?&gt;</pre><p>查看了自己的 Server 是否有支援 GZIP, 發現恰是一切正常.</p><pre class="brush: plain;">
HTTP_ACCEPT_ENCODING  gzip, deflate
_SERVER[&quot;HTTP_ACCEPT_ENCODING&quot;] gzip, deflate
_ENV[&quot;HTTP_ACCEPT_ENCODING&quot;] gzip, deflate
</pre><p>02. 於是分別在 .htaccess file 加上</p><p>a. 結果出現 HTTP 500 - Internal Server Error.</p><pre class="brush: php;">
php_flag zlib.output_compression on
php_value zlib.output_compression_level 4
</pre><p>b. 第二種沒反應  // that is, 不支持 mod_deflate</p><pre class="brush: php;">
&lt;ifmodule mod_deflate.c&gt;
DeflateCompressionLevel 4
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE js css
&lt;/ifmodule&gt;
</pre><p>03. 兩種都沒成功, 於是又上網 Google , 找了好久才發現如果主機有裝 <a href="http://www.suphp.org/" target="_blank">SuPHP</a>, 寫法會有不同, 要稍稍修正。</p><blockquote><p> When SuPHP is enabled, it is no longer possible to to include php_value directives in .htaccess files.</p><p>Instead of adding these directives to your .htaccess file, add them into a file called <font color="#ff0080">php.in</font></span> and place this file in the same directory that your script runs in. Most often this will be public_html directory, but in some cases you will install your script in a subdirectory. Wherever your script runs, this is the place for your php.ini file. You will need to <font color="#ff0080">drop the "php_flag" and "php_value" prefix.</font> You will also need to <font color="#ff0080">put an equals (=) sign between the setting and the value.</font></p></blockquote><p>a. 前面不要加上 "php_flag" and "php_value"<br /> b. 設定和值中間用 "=" 隔開<br /> c. 原本放在 .htaccess file -> 改放置在 php.ini file</p><p>eg:原本放 .htaccess file</p><pre class="brush: php;">
php_value max_execution_time 60
php_flag zlib.output_compression on
</pre><p>改後放 php.ini  // 目錄下沒 php.ini, 就自己創, 改好後再上傳, 非 php.ini.txt 喔</p><pre class="brush: php;">
max_execution_time = 60
zlib.output_compression = on
</pre><p>所以原本在 .htaccess file 的寫法, 要改成下面的樣子, 然後放置於 php.ini</p><pre class="brush: php;">
zlib.output_compression = on
zlib.output_compression_level = 4
</pre><p>04. 最後, 別忘了來 <a href="http://www.gidnetwork.com/tools/gzip-test.php" target="_blank">Gzip Test</a> 驗收成果</p><p>ps.<br /> a. 如果啟用 Gzip 出現 HTTP 500 - Internal Server Error, 很可能就是您的虛擬主機有使用 <a href="http://www.suphp.org/" target="_blank">SuPHP</a><br /> b. <a href="http://www.justhost.com/" target="_blank">JustHost</a> 有使用 <a href="http://www.suphp.org/" target="_blank">SuPHP</a><br /> c. 沒特別設定 compression level 的話, 預設是6, 數字可以是 1~9<br /> d. Compression test : 32,380 bytes  // 超過 4 級就沒什麼差別了</p><blockquote><p> Level 1:  9,161 bytes  71.7%<br /> Level 2:  8,915 bytes  72.5%<br /> Level 3:  8,757 bytes  73.0%<br /> Level 4:  8,400 bytes  74.1%<br /> Level 5:  8,215 bytes  74.6%<br /> Level 6:  8,155 bytes  74.8%<br /> Level 7:  8,120 bytes  74.9%<br /> Level 8:  8,108 bytes  75.0%<br /> Level 9:  8,100 bytes  75.0%</p></blockquote><p>Ref:<br /> 01. <a href="http://www.hostingcustomers.com/showthread.php?tid=416" target="_blank">All servers having SuPHP installed for added security</a><br /> 02. <a href="http://www.mybelovedphp.com/2006/11/29/how-to-use-gzip-compression-on-your-php-websites/" target="_blank">How to use gzip compression on your PHP websites</a><br /> 03. <a href="http://falcon1986.wordpress.com/2009/01/29/forcing-gzip-compression-on-your-hostmonster-hosted-website/" target="_blank">Force GZIP compression on your HostMonster-hosted website</a><br /> 04. <a href="http://www.venasun.com/blog/10/gzip-files" target="_blank">GZIP files</a></p> ]]></content:encoded> <wfw:commentRss>http://who-know.com/enable-gzip-compression-with-suphp-installed/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>