请稍候...
  • 企业级 VPS主机
  • Windows VPS 主机
  • Unmanaged VPS 主机
  • 通配符证书,部署全网SSL证书必备神器
  • 高速稳定独立主机High quality stable server

怎么开启cpanel/WHM全局优化选项Optimize Website

发布时间:2011-09-03 10:49:18 来源: solidservers

This will be a quick one folks.  The Apache module mod_deflate helps in reducing the size of the information sent to a user, by compressing things prior.  It seems to work very well.  To test if your site already has mod_deflate installed and working, you can go here:

http://www.whatsmyip.org/http_compression/

To enable mod_deflate on your WHM / cPanel server, make sure you run EasyApache through WHM, and select to install mod_deflate.  Once done, you’ll notice that it is not active globally.  In your cPanel control panel for your domain, you should notice that under “Software / Services” an icon called “Optimize Website” is now there.  This is how you control mod_deflate on a per user basis.

If however, you wish enable it globally, so that all websites on your server can benifit from this, you need to venture back into WHM, and this time go to:

Services Configuration >> Apache Configuration >> Include Editor >> Post VirtualHost Include, and select All Versions

Now, paste the following into this file, and hit Update:


SetOutputFilter DEFLATE

# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary


# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary

That’s it, now, go back to the site I gave you at the start, load up your website, and verify that compression is now functioning.

For you command line users, you can achieve this my running the easy apache command line build (/scripts/easyapache), and select to include mod_deflate.  Once that is done, you can edit the “/usr/local/apache/conf/includes/post_virtualhost_2.conf” file, and paste the above code into it to achieve the same results.  Remember to restart apache once you’ve edited the file.

上一页1下一页
【责任编辑:亚狐科技 (Top) 返回页面顶端