Squid should now be configured, and the directories should have the correct permissions. We should now be able to start Squid, and you can try and access the cache with a web browser. Squid is normally run by starting the RunCache script. RunCache (as mentioned ealier) restarts Squid if it dies for some reason, but at this stage we are merely testing that it will run properly: we can add it to startup scripts at a later stage.
Programs which handle network requests (such as inetd and sendmail) normally run in the background. They are run at startup, and log any messages to a file (instead of printing it to a screen or terminal, as most user-level programs do.) These programs are often referred to as daemon programs. Squid is such a program: when you run the squid binary, you should be immediately returned to the command line. While it looks as if the program ran and did nothing, it's actually sitting in the background waiting for incoming requests. We want to be able to see that Squid's actually doing something useful, so we increase the debug level (using -d 1) and tell it not to dissapear into the background (using -N.) If your machine is not connected to the Internet (you are doing a trial squid-install on your home machine, for example) you should use the -D flag too, since Squid tries to do DNS lookups for a few common domains, and dies with an error if it is not able to resolve them.
The following output is that printed by a default install of Squid:
cache1:~ # /usr/local/squid/bin/squid -N -d 1 -D 1999/06/12 19:16:20| Starting Squid Cache version 2.2.DEVEL3 for i586-pc-linux-gnu... 1999/06/12 19:16:20| With 256 file descriptors available 1999/06/12 19:16:20| Loaded Icons. 1999/06/12 19:16:20| Accepting HTTP connections on port 3128, FD 35. 1999/06/12 19:16:20| storeRebuildFromDirectory: DIR #0 done!
Squid reads the config file, and changes user-id's here:
Each concurrent incoming request uses at least one
filedescriptor. 256 filedescriptors is only enough for a small,
lightly loaded cache server, see Chapter 12 for more details.
Most of the following is diagnostic:
1999/06/12 19:16:20| Process ID 4121
When you connect to an ftp server without a cache, your browser
chooses icons to match the files based on their filenames. When you
connect through a cache server, it assumes that the page returned will
be in html form, and will include tags to load any images so that the
directory listing looks normal.
Squid adds these tags, and has a collection of icons that it refers
clients to. These icons are stored in
/usr/local/squid/etc/icons/. If Squid has permission problems
here, you need to make sure that these files are owned by the
appropriate users (in the previous section we set permissions on the
files in this directory.)
1999/06/12 19:16:20| helperOpenServers: Starting 5 'dnsserver' processes
1999/06/12 19:16:20| Unlinkd pipe opened on FD 13
1999/06/12 19:16:20| Swap maxSize 10240 KB, estimated 787 objects
1999/06/12 19:16:20| Target number of buckets: 15
1999/06/12 19:16:20| Using 8192 Store buckets, replacement runs every 10 seconds
1999/06/12 19:16:20| Max Mem size: 8192 KB
1999/06/12 19:16:20| Max Swap size: 10240 KB
1999/06/12 19:16:20| Rebuilding storage in Cache Dir #0 (DIRTY)
The next few lines are the most important. Once you see the Ready to serve requests line, you should be able to start using the cache
server. The HTTP port is where Squid is waiting for browser
connections, and should be the same as whatever we set it to in the
previous chapter. The ICP port should be 3130, the default, and if you
have included other protocols (such as HTCP) you should see them here.
If you see permission denied errors here, it's possible that you are
trying to bind to a low-numbered port (like 80) as a normal user. Try
run the startup command is root, or (if you don't have root access on
the machine) choose a high-numbered port.
Another common error message at this stage is Address already in use. This occurs when another process is already listening to the
given port. This could be because Squid is already started (perhaps
you are upgrading from an older version which is being restarted by
the RunCache script) or you have some other process listening on the
same port (such as a web server.)
Once Squid is up-and-running, it reads the cache-store. Since we are
starting Squid for the first time, you should see only zeros for all
the numbers below:
1999/06/12 19:16:20| Accepting ICP messages on port 3130, FD 36.
1999/06/12 19:16:20| Accepting HTCP messages on port 4827, FD 37.
1999/06/12 19:16:20| Ready to serve requests.
1999/06/12 19:16:25| Finished rebuilding storage disk.
1999/06/12 19:16:25| 0 Entries read from previous logfile.
1999/06/12 19:16:25| 0 Entries scanned from swap files.
1999/06/12 19:16:25| 0 Invalid entries.
1999/06/12 19:16:25| 0 With invalid flags.
1999/06/12 19:16:25| 0 Objects loaded.
1999/06/12 19:16:25| 0 Objects expired.
1999/06/12 19:16:25| 0 Objects cancelled.
1999/06/12 19:16:25| 0 Duplicate URLs purged.
1999/06/12 19:16:25| 0 Swapfile clashes avoided.
1999/06/12 19:16:25| Took 5 seconds ( 0.0 objects/sec).
1999/06/12 19:16:25| Beginning Validation Procedure
1999/06/12 19:16:26| storeLateRelease: released 0 objects
1999/06/12 19:16:27| Completed Validation Procedure
1999/06/12 19:16:27| Validated 0 Entries
1999/06/12 19:16:27| store_swap_size = 21k
cache1:~ # /usr/local/squid/bin/squid -N -d 1 -D
1999/06/12 19:16:20| Starting Squid Cache version 2.2.DEVEL3 for i586-pc-linux-gnu...
1999/06/12 19:16:20| With 256 file descriptors available
1999/06/12 19:16:20| Loaded Icons.
1999/06/12 19:16:20| Accepting HTTP connections on port 3128, FD 35.
1999/06/12 19:16:20| storeRebuildFromDirectory: DIR #0 done!