Installing and Configuring Squid - Get it Up and Running!
(Page 2 of 4 )
As always with software, the first step is downloading the release package. You can read important information regarding the several ways to obtain Squid from this page. Technically, Squid already comes in numerous distribution packages or can be acquired via their ports/package systems (by downloading). If not, you can opt for downloading the source code and compiling it yourself or just going with the binary package.
For the purpose of this article we're installing Squid on a test Linux machine that runs the Gentoo Linux distribution. One of the specific traits of this distro is that it heavily relies on a so-called Portage system. Portage is package management software. And under Gentoo you can grab ebuilds for over 25,000 applications. Of course, Squid is available in Portage too. So the following two commands are Gentoo-specific:
emerge --sync
emerge squid
Executing the above two commands first sync the Portage system and then grab and install Squid. Pay close attention to the outcome of the process. Everything is printed to the console output. Now we need to create the cache directory for Squid. We will do this into the /mnt folder, for example. All right, we still need to configure the user squid with the necessary permissions for that newly-created directory.
mkdir /mnt/cache
chown -R squid:squid /mnt/cache
In most cases, Squid is installed under the /usr/local/squid directory. The official documentation advises mounting the cache under /usr/local/squid/cache but we can do this anywhere else too, just as we've done above. This is not a requirement.
The official guide (which is composed of excerpts of the book) also recommends setting up a user squid and a group squid, with the home directory of /usr/local/squid. Should you allow more users access to the configuration files, you should set the permissions accordingly. It's going to run as a daemon under the user nobody and group nogroup, as every other daemon. But we'll alter this later on.
Now that we have done the majority of installation steps, we still have to configure. You can find the squid.conf configuration file under the /usr/local/squid/etc folder. We need to modify that file according to our specific requirements. First of all, let's discuss each command line by line. This approach is more understandable than copying and pasting the entire configuration file and then explaining. We will present just the bare minimum!
By default, Squid runs on the 3128 port. This port is widely known because Squid runs under this port by default, unlike other proxies, which run under 8080. However, this can be modified, if need be. You should choose a port number higher than 1024, because those are part of the "untrusted" ports and do not require administrative access.
http_port 192.168.1.1:8080
Moving on, let's define the host name of the Squid caching proxy server.
visible_hostname proxy_srv
All right, now let's speed up the process and set the caching directory that we just created earlier. This is when we also need to specify the maximum size of the cache. Right now we'll create a ~10GB cache. Mind you, the exact size will be 10,000MB. Once that's done, we also want to modify the user and group under which Squid should run.
# we created the /mnt/cache earlier
cache_dir ufs /mnt/cache 10000 16 256
# now comes the user/group part
cache_effective_user squid
cache_effective_group squid
On the next page we will configure the necessary ACLs-access control lists, among other specifics such as allowing only our LAN users and the logging place.
Next: More, More... Configuration! >>
More Server Administration Articles
More By Barzan 'Tony' Antal