Google Answers Logo
View Question
 
Q: Squid Configuration ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: Squid Configuration
Category: Computers > Operating Systems
Asked by: linuxgirl-ga
List Price: $10.00
Posted: 08 Oct 2004 17:10 PDT
Expires: 07 Nov 2004 16:10 PST
Question ID: 412284
I need the required steps to configure squid in my newly installed
Redhat 9.0 linux. Please your steps should be self explanatory
"because i am new to Linux".
Answer  
Subject: Re: Squid Configuration
Answered By: leapinglizard-ga on 08 Oct 2004 17:42 PDT
Rated:5 out of 5 stars
 
Dear linuxgirl,

Squid is a proxy web server that caches recently accessed content for
fast repeated access. If you are not interested in this functionality,
you probably don't need squid.


Step 0: Install

My own Red Hat 9.0 installation already includes squid. If yours doesn't,
you'll want to install the squid-2.5 RPM from disc 1 of the Red Hat 9.0
distribution. Load the disc into your CD-ROM drive and switch to root
using the su command. If your CD-ROM drive mounts under /mnt/cdrom,
you'll have the following dialogue.

> su
Password:
# rpm -ivh /mnt/cdrom/RedHat/RPMS/squid-2.5.STABLE1-2.i386.rpm
warning: /mnt/cdrom/RedHat/RPMS/squid-2.5.STABLE1-2.i386.rpm: V3 DSA
signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:squid                  ########################################### [100%]
#

Leave root mode by typing Ctrl-D.


Step 1: Prepare

The squid configuration file is now located at /etc/squid/squid.conf .

You can look it over as an ordinary user, but to edit it, you'll have
to be root. Most of the variables will not be relevant to you, but you
should at least review the following ones. Search for each variable
name with your favorite word processor -- I use vim -- and look for the
line containing it under the heading "Default:". Copy this line, then
uncomment the variable definition by removing the '#' character. Now
you can change the value to suit your needs.

cache_mem
    This is the amount of RAM you can spare for the cache alone,
    but Squid will use about three times this amount in total. Since
    I can spare 100 megabytes for Squid, I set cache_mem to 33 megs.

    cache_mem 33 MB

cache_dir
    The first argument here is the type of file system used for the
    cache, which you should leave at the default value of ufs. The
    second argument is the directory where the cache will be
    stored. I suggest you switch to root mode and make a directory
    called /var/local/squid , then change its owner to a non-root
    user. My username is mike, so I execute the following.

# mkdir /var/local/squid
# sudo chown mike:mike /var/local/squid

    If you have lots of hard disk space, you can set the third
    argument to 250 or 500. Otherwise, leave the numbers as they are.

    cache_dir ufs /var/local/squid/cache 100 16 256

error_directory
    Squid can output informative error messages if you set this
    properly. In the case of a Red Hat 9.0 installation, the error
    messages should be in /usr/share/squid/errors/English .

    error_directory /usr/share/squid/errors/English

pid_filename
    This is the name of a small file where Squid writes its process
    ID. Since you probably want to run Squid as a non-root user for
    safety, you should first make a file as root in the /var/run
    directory, then change its owner to yourself.

# echo 0 > /var/run/squid.pid
# chown mike:mike /var/run/squid.pid

    pid_filename /var/run/squid.pid

To make sure you haven't made any syntax errors in modifying the
configuration file, run "squid -k parse". If there is no output,
everything is fine.


Step 2: Execute

You must now run squid several times. First, run it with the -z option
to set up the cache directories.

> squid -z
2004/09/27 11:27:55| Creating Swap Directories

Now run it in debug mode to make sure it's working fine.

> squid -NCd1

You should get lots of output from that, including a line that reads
"Ready to serve requests."

From another terminal window, test the squid server by running squidclient
on a few websites.

> squidclient http://google.com
HTTP/1.0 302 Moved Temporarily
Location: ://www.google.com/
Set-Cookie:
PREF=ID=66dda52c53fe2384:TM=1096298999:LM=1096298999:S=1A9RwweQxPXhFEUg;
expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
Content-Type: text/html
Server: GWS/2.1
Content-Length: 152
Date: Mon, 27 Sep 2004 15:29:59 GMT
X-Cache: MISS from pegasus.somethingisaid.com
Proxy-Connection: close

<HTML><HEAD><TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="://www.google.com/">here</A>.
</BODY></HTML>

To stop the squid server, type Ctrl-C in the terminal from which
you launched it. To run squid in silent mode, execute it without any
command-line options. You can now confirm that it is running by searching
for its name among the active processes.

> squid
> ps -A | grep squid
14635 ?        00:00:00 squid
14637 ?        00:00:00 squid

If these steps don't work as I've described them and you're quite sure
you've followed my instructions to the letter, get back to me so I can
help you debug. 
    
There is an extensive FAQ at the following address. In reading it,
you should not assume that every configuration detail applies to you,
since you have an older, RPM-based installation of the Squid package.

SQUID Frequently Asked Questions
http://www.squid-cache.org/Doc/FAQ/FAQ.html

If you feel that my answer is incomplete or inaccurate in any way, please
post a clarification request so that I have a chance to meet your needs
before you assign a rating.

Regards,

leapinglizard

Request for Answer Clarification by linuxgirl-ga on 09 Oct 2004 13:16 PDT
Thank you for your answer. Could you please explain better your
statement (look for the line containing it under the heading
"Default:". Copy this line, then uncomment the variable definition by
removing the '#' character. Now you can change the value to suit your
needs). Where am i suppose to copy the line containing defualt to? and
how do i save changes made to the squid configuration file. Please try
to be as simple as possible.

Clarification of Answer by leapinglizard-ga on 09 Oct 2004 13:49 PDT
> Where am i suppose to copy the line containing defualt to?

Don't copy the line containing "Default:", but the line beneath it.
Copy the whole line and paste it immediately beneath the original.
Then remove the "# " at the beginning, so that it is no longer a
comment but an active line. Copying is not necessary, but I recommend
it as a means of preserving a record of the default values.

Now that you have copied and uncommented the line, you can change the
variable settings as you wish.


> how do i save changes made to the squid configuration file.

This depends on what text editor you're using to edit the file. If you
tell me what editor you're using, perhaps I'll be able to find out
what the Save command is in your particular case. It is probably a
fairly obvious menu item or key combination. If you're using kedit,
for example, you can save the file by typing Ctrl-S or by selecting
the Save item from the File menu.


leapinglizard
linuxgirl-ga rated this answer:5 out of 5 stars
Thank you for your clarification. You are the best teacher i have ever
meant. Keep it up.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy