Time for action – exploring Squid files
Let's have a look at the files and directories generated during installation. The easiest way to checkout the directories and files generated is to use the tree
command. If the tree
command is not available, we can list files using the ls
command as well.
tree ${prefix} | less
${prefix}
is the directory used with the --prefix
option for configure
. Now let's have a brief overview at the important files generated by Squid during installation. All of the following directories and files listed, reside in ${prefix}
:
bin
This directory contains programs which can be executed or run by a user without root or super user privileges.
bin/squidclient
squidclient
is a HTTP client with advanced capabilities, which allow it to tinker HTTP requests to test the Squid server. Run squidclient
to checkout the available options:
${prefix}/bin/squidclient
etc
This is the place where for all the configuration files related to Squid are located.
Note
It's a good idea to use the --sysconfdir=/etc/squid/
option with configure
, so that you can share the configuration across different Squid installations while testing.
etc/squid.conf
This is the default location for the Squid configuration file. The squid.conf
generated during installation is the bare minimum configuration required for Squid to be used. We always make changes to this file if we need to alter the Squid configuration.
etc/squid.conf.default
Squid generates this default configuration file so that we can copy and rename it to squid.conf
and start afresh.
etc/squid.conf.documented
This is a fully documented version of squid.conf
, containing thousands of lines of comments. We should always refer to this file for the available configuration tags for the version of Squid when we have installed.
libexec
This directory contains helper programs built during Squid compilation.
libexec/cachemgr.cgi
This CGI program provides a web interface for managing the Squid cache called Cache Manager.
sbin
This directory contains programs which can only be executed by a user with root or super user privileges.
sbin/squid
This is the actual Squid program, which is generally run as a daemon.
share
This is the location for error page templates, documentation, and other files used by Squid.
share/errors
This directory contains localized error page templates. The templates are HTML pages and we can customize the error messages displayed by Squid, by modifying these HTML templates.
share/icons
This directory contains a number of small images used for FTP or gopher directory listing.
share/man
This is the place where the man
pages for squid
, squidclient
, and helpers are built during compilation. Man
pages are manual or help pages which can be viewed using the command man
(available on all Linux/Unix distributions). To view a man
page located at /opt/squid/share/man/man8/squid.8
, we can use the man
command as follows:
man /opt/squid/share/man/man8/squid.8
For more details about man pages, please visit http://en.wikipedia.org/wiki/Man_page.
var
A place for files that change frequently while Squid is running.
var/cache
This is the default directory for storing the cached web documents on a hard disk.
var/logs
This is the default home for all the log files (such as cache.log
, access.log
, and so on) used by Squid.
What just happened?
We have just looked at the various files and directories generated during installation and a had brief overview of what each directory contains.
Installing Squid from binary packages
Squid binary packages are available in the software repositories of most operating systems and we can install them by using the package managers provided by the respective operating systems. Next, we'll see how to use a package manager on a few operating systems to install Squid.
Note
The latest or beta versions may not be available in software repositories of all the operating systems. In such cases, we should get the latest or beta versions from the Squid website, as explained earlier in this chapter.
Fedora, CentOS or Red Hat
Yum is a popular package manager on RPM-based operating systems. Squid RPM is available in the Fedora, CentOS, and Red Hat repositories. To install Squid, we can simply use the following command:
yum install squid
Debian or Ubuntu
We can use apt-get
to install Squid on Debian or Ubuntu:
apt-get install squid3
FreeBSD
Squid is available in the FreeBSD ports collection. The following command can be used to install Squid on FreeBSD:
pkg_add -r squid31
For more information on package management in FreeBSD, please go to http://www.freebsd.org/doc/handbook/packages-using.html.
OpenBSD or NetBSD
Installing Squid on OpenBSD or NetBSD is similar to installing it on FreeBSD and can be performed using the following command:
pkd_add squid31
To learn more about the package management system in OpenBSD and NetBSD, please refer to http://www.openbsd.org/ports.html#Get and http://www.netbsd.org/docs/pkgsrc/using.html#installing-binary-packages respectively.
Dragonfly BSD
To install Squid on Dragonfly BSD, we can use the following command:
pkg_radd squid31
For more information on installing binary packages on Dragonfly BSD, please visit http://www.dragonflybsd.org/docs/newhandbook/pkgsrc/.
Gentoo
We can install Squid on Gentoo Linux using emerge
, as shown next:
emerge =squid-3.1*
Arch Linux
To install Squid on Arch Linux, we can use the package manager pacman
, as shown in the following command:
pacman -S squid
For more information on pacman
, please visit https://wiki.archlinux.org/index.php/Pacman.
Pop quiz
Which of the following web documents can't be cached by a proxy server?
A HTML page
A JPEG image
A PHP script that produces output based on a client's IP Address
A JavaScript file
In which of the following scenarios, should we worry about the
--enable-diskio
option?Caching in RAM (main memory) is enabled
Caching on hard disk is enabled
Caching is disabled
None of the above
When does a removal policy selection affect the overall Squid performance?
If caching is disabled
If caching on the hard disk and RAM is enabled
A removal policy selection is not related to caching
A removal policy doesn't affect overall Squid performance