How to Install Squid (Caching / Proxy) on Ubuntu 12.04 LTS

Squid is a caching and forwarding web proxy. It is most often used in conjunction with a traditional LAMP stack (Linux, Apache, MySQL, PHP), and can be used to filter traffic on HTTP, FTP, and HTTPS, and increase the speed (thus lower the response time) for a web server via caching.

Pre-Flight Check
  • These instructions are intended specifically for installing Squid on a single Ubuntu 12.04 LTS node.
  • I’ll be working from a Liquid Web Core Managed Ubuntu 12.04 LTS server, and I’ll be logged in as root.

Step #1 Install Squid

As a matter of best practice we’ll update our packages:

apt-get update

Then let’s install Squid and any required packages:

apt-get install squid

Step #2: Verify and Checking the Version of the Squid the Installation

Squid should start immediately after the installation. Use the following command to view information on the command:

squid3 -h

Use the following command to check the version number of Squid and the configuration options it was started with:

squid3 -v

Your results should appear similar to:

Squid Cache: Version 3.1.19
configure options: ‘–build=x86_64-linux-gnu’ ‘–prefix=/usr’ ‘–includedir=${prefix}/include’ ‘–mandir=${prefix}/share/man’ ‘–infodir=${prefix}/share/info’ ‘–sysconfdir=/etc’ ‘–localstatedir=/var’ ‘–libexecdir=${prefix}/lib/squid3’ ‘–srcdir=.’ ‘–disable-maintainer-mode’ ‘–disable-dependency-tracking’ ‘–disable-silent-rules’ ‘–datadir=/usr/share/squid3’ ‘–sysconfdir=/etc/squid3’ ‘–mandir=/usr/share/man’ ‘–with-cppunit-basedir=/usr’ ‘–enable-inline’ ‘–enable-async-io=8’ ‘–enable-storeio=ufs,aufs,diskd’ ‘–enable-removal-policies=lru,heap’ ‘–enable-delay-pools’ ‘–enable-cache-digests’ ‘–enable-underscores’ ‘–enable-icap-client’ ‘–enable-follow-x-forwarded-for’ ‘–enable-auth=basic,digest,ntlm,negotiate’ ‘–enable-basic-auth-helpers=LDAP,MSNT,NCSA,PAM,SASL,SMB,YP,DB,POP3,getpwnam,squid_radius_auth,multi-domain-NTLM’ ‘–enable-ntlm-auth-helpers=smb_lm,’ ‘–enable-digest-auth-helpers=ldap,password’ ‘–enable-negotiate-auth-helpers=squid_kerb_auth’ ‘–enable-external-acl-helpers=ip_user,ldap_group,session,unix_group,wbinfo_group’ ‘–enable-arp-acl’ ‘–enable-esi’ ‘–enable-zph-qos’ ‘–enable-wccpv2’ ‘–disable-translation’ ‘–with-logdir=/var/log/squid3’ ‘–with-pidfile=/var/run/squid3.pid’ ‘–with-filedescriptors=65536’ ‘–with-large-files’ ‘–with-default-user=proxy’ ‘–enable-linux-netfilter’ ‘build_alias=x86_64-linux-gnu’ ‘CFLAGS=-g -O2 -fPIE -fstack-protector –param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security’ ‘LDFLAGS=-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now’ ‘CPPFLAGS=-D_FORTIFY_SOURCE=2’ ‘CXXFLAGS=-g -O2 -fPIE -fstack-protector –param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security’ –with-squid=/build/buildd/squid3-3.1.19

Step #3: Configure Squid to Start at Boot

update-rc.d squid3 defaults

And verify that Squid will start on boot:

initctl show-config squid3

You should receive a result similar to:

squid3
start on runlevel [2345]
stop on runlevel [!2345]

This means that Squid will start on runlevels 2, 3, 4, and 5.

For more information on Linux runlevels, visit our tutorial on: Linux Runlevels Explained

Be Sociable, Share!
Here's $75, Launch a New VPS Today. Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7 Heroic Support.