Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to make the webserver in Snow Leopard compress all output by default. The only thing I have found is to add SetOutputFilter DEFLATE in the .htaccess file for a directory.

I really don't want to add an .htaccess file to every directory served.

How can I globally get Apache2 on Snow Leopard to compress output?

share|improve this question
add comment

2 Answers

Add the output filter to the configure file (make sure you have Server Admin closed) /etc/apache2/httpd.conf.

If you're using virtual hosts you can do it on a per-domain-basis inside /etc/apache2/sites/.

share|improve this answer
    
Where do I add the line so that it is global to all pages, directories and sites? I tried adding to the end of the file, but no go. –  gbrandt Mar 23 '10 at 15:58
add comment

I put this in /etc/apache2/other/deflate.conf (which I created):

AddOutputFilterByType DEFLATE text/html text/xml text/css application/javascript application/xml+xhtml

After adding this file, or adding this directive to httpd.conf, you have to restart Apache. In Terminal.app, you can do 'sudo apachectl restart' to accomplish this.

You don't want to do a blanket 'AddOutputFilter DEFLATE' because then the server will try to compress all files, including files that are already compressed - JPEG images, PNGs, video/movie files, MP3s, etc. - which will make it much slower to serve those files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.