| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 6222|Reply: 3
Collapse the left

How to open GZip for your Discuz!

[Copy link]

 China

Post time: 2013-09-28 14:02
| Show all posts |Read mode
本帖最后由 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 compressYes
Typegzip
Original33277 bytes
After8631 bytes
Percent74.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.
  1. LoadModule deflate_module modules/mod_deflate.so
  2. 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.
  1. <IfModule mod_deflate.c>

  2. #Necessary, tell your apache to compress
  3. SetOutputFilter DEFLATE

  4. #compress rate 1~9, suggest 6
  5. DeflateCompressionLevel 6

  6. #set to not compress gif,jpg,jpeg,png, because no much use and cost your CPU too much
  7. SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

  8. #like above , but set to exe, tgz, gz..etc
  9. SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
  10. SetEnvIfNoCase Request_URI .(?:pdf|mov|avi|mp3|mp4|rm)$ no-gzip dont-vary

  11. #Set to work with text/html  text/css  text/plain, etc
  12. AddOutputFilterByType DEFLATE text

  13. #It will work on javascript files
  14. AddOutputFilterByType DEFLATE application/ms* application/vnd* application/postscript application/javascript application/x-javascript

  15. #It will work on php files
  16. AddOutputFilterByType DEFLATE application/x-httpd-php application/x-httpd-fastphp

  17. #Netscape 4.x has some problem with this function, so only conpress text/html
  18. BrowserMatch ^Mozilla/4 gzip-only-text/html

  19. #Netscape 4.06-4.08 has more problem, not open for them
  20. BrowserMatch ^Mozilla/4.0[678] no-gzip

  21. # A hack for IE, seems like for resolve some problem, I don't know the details
  22. BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  23. </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

Number of participants 1Rating +1 Collapse Reason
Pme + 1 Usefull

View Rating Log

Post time: 2013-09-29 06:46
| Show all posts
Another Way is to Simply add These Lines to .htaaccess and save...

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Post time: 2013-10-05 04:12
| Show all posts
i tried your method i addded the code to htaccess and enabled gzip in config but got internal server error 500

 Russia

Post time: 2013-10-05 19:28
| Show all posts
Ask your hosting support to check if mod_deflate is enabled.
You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-11-22 04:39 GMT+3 , Processed in 0.046227 sec., 10 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list