PDA

Click to See Complete Forum and Search --> : Linux Squid + Apache Setup Guide


Evan
Feb 5th, 2004, 10:34 AM
Squid recieves all requests, and tries to handle requests out of cache.

This can literally make your server 100x faster.

HIT = In cache, no need to ask Apache
MISS = Not in cache, or expired, ask Apache

MAMBO

We had to hack Mambo, since it is setup to NOT be cached. It has an Always "Modified" header plus an "Expires" in the past. I may have also erased some Pragma lines. (egrep -rn Pragma)....

Edit index.php like so:

// Add this line, cache content up to 1 hour
header ("Cache-Control: max-age=3600");
//header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Drop this
//header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Apache will add this automagically

Apache NOTE: if you want ssl and apache, change and restart both

Here's the 1 change we made to Apache's /etc/apache/httpd.conf:

BindAddress? 127.0.0.1

Squid


1.) sudo cp /etc/squid.conf /etc/squid.conf.old
2.) sudo rm /etc/squid.conf

/etc/squid.conf looks like so:

# All access from everywhere
acl all src 0.0.0.0/0.0.0.0
http_access allow all

#Set the outside IP here
#put my ip address where it says 255.1.1.1
http_port 255.1.1.1:80

hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY

#Here's the reverse proxy goodies
httpd_accel_host 127.0.0.1
httpd_accel_port 80
httpd_accel_single_host on
httpd_accel_uses_host_header on

CONCLUSION:

It is WAAAY faster, for front page accesses. We went from a load of 10.00 to .20 within a few minutes. Anything accessing the shopping cart or with "index.php?" in it IS NOT cached, from what I see. Also some images are still TCP_MISS. For some reason. It works IMHO, very well.

Extra notes:

Failed opening required 'DB.php' MEANS -- you don't have PEAR, (apt-get install php4-pear)

Other modules you'll need:

apt-get install apache squid php4-mysql php4-pear php4 mysql-server phpmyadmin apache-ssl

Setup phpmyadmin ONLY on Apache-SSL

Customize /etc/squid.conf with above fixes

Customize /etc/apache/httpd.conf with above

Restart them both