China
|
本帖最后由 leon 于 2013-9-28 19:48 编辑
I just finished config, and I find it worth to share.
Because it improve your discuz!x's visit speed obviously.
Test result Whether compress | Yes | Type | gzip | Original | 33277 bytes | After | 8631 bytes | Percent | 74.06%
|
My VPS is a centos 6.4 server, so I will show you about the procedure in a simple way.
1. Check your /etc/httpd/conf/httpd.conf, make sure they are available.- LoadModule deflate_module modules/mod_deflate.so
- LoadModule headers_module modules/mod_headers.so
Copy the Code 2. Add the code to your httpd.conf, if you use a visual host, add to .htcaccess.- <IfModule mod_deflate.c>
- #Necessary, tell your apache to compress
- SetOutputFilter DEFLATE
- #compress rate 1~9, suggest 6
- DeflateCompressionLevel 6
- #set to not compress gif,jpg,jpeg,png, because no much use and cost your CPU too much
- SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
- #like above , but set to exe, tgz, gz..etc
- SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
- SetEnvIfNoCase Request_URI .(?:pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary
- #Set to work with text/html text/css text/plain, etc
- AddOutputFilterByType DEFLATE text
- #It will work on javascript files
- AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript application/javascript application/x-javascript
- #It will work on php files
- AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp
- #Netscape 4.x has some problem with this function, so only conpress text/html
- BrowserMatch ^Mozilla/4 gzip-only-text/html
- #Netscape 4.06-4.08 has more problem, not open for them
- BrowserMatch ^Mozilla/4.0[678] no-gzip
- # A hack for IE, seems like for resolve some problem, I don't know the details
- BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
- </IfModule>
Copy the Code 3. Modify configuration in Discuz. Open"/config/config_global.php"
Replace:
$_config['output']['gzip'] ='0';
To:
$_config['output']['gzip']= '1';
4. restart your apache.
#service httpd restrat
5. Test your site here. It is a chinese site, you can translate it by google.
http://tool.chinaz.com/Gzips/
Tips: How to verify whether your apache server support Gzip?
1. Input by cmd line: #httpd -M
2. Check these 2 module.
deflate_module (shared)
headers_module (shared)
|
Rate
-
View Rating Log
|