You must download a source archive file of the form squid-x.y.z-src.tar.gz (eg, squid-1.1.6-src.tar.gz) from the Squid home page, or. the Squid FTP site. Context diffs are available for upgrading to new versions. These can be applied with the patch program (available from the GNU FTP site).
For Squid-1.0 and Squid-1.1 versions, you can just type make from the top-level directory after unpacking the source files. For example:
% tar xzf squid-1.1.21-src.tar.gz % cd squid-1.1.21 % make
For Squid-2 you must run the configure script yourself before running make:
% tar xzf squid-2.0.RELEASE-src.tar.gz % cd squid-2.0.RELEASE % ./configure % make
To compile Squid, you will need an ANSI C compiler. Almost all modern Unix systems come with pre-installed compilers which work just fine. The old SunOS compilers do not have support for ANSI C, and the Sun compiler for Solaris is a product which must be purchased separately.
If you are uncertain about your system's C compiler, The GNU C compiler is available at the GNU FTP site. In addition to gcc, you may also want or need to install the binutils package.
The developers do not have the resources to make pre-compiled binaries available. Instead, we invest effort into making the source code very portable. Some people have made binary packages available. Please see our Platforms Page.
You need the patch
program. You should probably duplicate the
entire directory structure before applying the patch. For example, if
you are upgrading from squid-1.1.10 to 1.1.11, you would run
these commands:
cd squid-1.1.10 mkdir ../squid-1.1.11 find . -depth -print | cpio -pdv ../squid-1.1.11 cd ../squid-1.1.11 patch < /tmp/diff-1.1.10-1.1.11After the patch has been applied, you must rebuild Squid from the very beginning, i.e.:
make realclean ./configure make make installNote, In later distributions (Squid 2), 'realclean' has been changed to 'distclean'.
If your patch
program seems to complain or refuses to work,
you should get a more recent version, from the
GNU FTP site, for example.
The configure script can take numerous options. The most
useful is --prefix
to install it in a different directory.
The default installation directory is /usr/local/squid/. To
change the default, you could do:
% cd squid-x.y.z % ./configure --prefix=/some/other/directory/squid
Type
% ./configure --helpto see all available options. You will need to specify some of these options to enable or disable certain features. Some options which are used often include:
--prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/squid] --enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea --enable-gnuregex Compile GNUregex --enable-splaytree Use SPLAY trees to store ACL lists --enable-xmalloc-debug Do some simple malloc debugging --enable-xmalloc-debug-trace Detailed trace of memory allocations --enable-xmalloc-statistics Show malloc statistics in status page --enable-carp Enable CARP support --enable-async-io Do ASYNC disk I/O using threads --enable-icmp Enable ICMP pinging --enable-delay-pools Enable delay pools to limit bandwith usage --enable-mem-gen-trace Do trace of memory stuff --enable-useragent-log Enable logging of User-Agent header --enable-kill-parent-hack Kill parent on shutdown --enable-snmp Enable SNMP monitoring --enable-time-hack Update internal timestamp only once per second --enable-cachemgr-hostname[=hostname] Make cachemgr.cgi default to this host --enable-arp-acl Enable use of ARP ACL lists (ether address) --enable-htpc Enable HTCP protocol --enable-forw-via-db Enable Forw/Via database --enable-cache-digests Use Cache Digests see http://squid.nlanr.net/Squid/FAQ/FAQ-16.html --enable-err-language=lang Select language for Error pages (see errors dir)
The Squid Makefile includes numerous options that you may define before compiling. These enable certain customizations and/or non-standard features described below. As of this writing, the options below were present in the Squid 1.1.15 src/Makefile. If you want to define these before running configure then you would edit src/Makefile.in.
Normally the cachemgr.cgi program brings up the main HTML form with the hostname field blank. Some administrators grow weary from continually entering hostnames, so this option allows a default hostname to be set for that field.
Jon Thackray has written some optionally-compiled code to support proxy authentication. In addition to enabling this option in the Makefile, you must also define a password file with the proxy_auth option in squid.conf.
Mark Kennedy and Ron Gomes have written some optionally-compiled code to log FULL request and response headers to access.log. The headers are encoded safely and will appear as two bracketed fields at the end of each line. The log_mime_hdrs option must also be enabled in squid.conf.
This option enables using ICMP (ala ping) to measure the proximity of origin servers. This feature is fully described in using-icmp .
Mike Groeneweg has written some optionally-compiled code to delay the requests of certain users. Requests matching the delay_access ACL rules (similar to http_access) will be artificially delayed by the neighbor_timeout amount.
Joe Ramey has written some optionally-compiled code to log the value of the User-Agent request header to a separate useragent.log file.
When this option is defined, Squid sends a kill signal to its parent process (assuming it to be the RunCache script) when Squid terminates. This feature is a bit dangerous, so use at your own risk.
Some operating systems may perform better when the poll() function call is available. poll() would be used in place of select(). Solaris', select() only supports 1024 file descriptors (even if the process limit is higher). poll() should be used if you need more than 1024 descriptors on Solaris.
By default, Squid stores IP access list entries as a linked-list. Linear searches on these lists may be inefficient. This optionally-compiled code stores IP access lists as SPLAY trees. No analysis has been done to prove that this implementation is significantly more efficient, however.
Another option to linear linked-lists of IP access controls. With this option, binary balanced trees are used to store the access lists.
Some administrators have asked for the ability to change a no-cache request into an If-Modified-Since request. When this option is defined, Squid will strip the no-cache request header and insert an If-Modified-Since header with last-valid time of the cached object. If the request already includes an If-Modified-Since header, it will be unchanged. Use of this feature means that cache users will have no way to enforce a refresh if a bad or outdated page gets cached and the dates get out of sync, or if a partial object somehow becomes cached.
This adds the ability to use ACL entries to specify objects which should not be cached. This is a standard feature for Squid-2, and was added as a non-standard option to Squid-1.1 for some people who wanted it.
by Kevin Sartorelli and Andreas Doering.
Probably you've recently installed bind 8.x. There is a mismatch between the header files and DNS library that Squid has found. There are a couple of things you can try.
First, try adding -lbind
to XTRA_LIBS in src/Makefile.
If -lresolv
is already there, remove it.
If that doesn't seem to work, edit your arpa/inet.h file and comment out the following:
#define inet_addr __inet_addr #define inet_aton __inet_aton #define inet_lnaof __inet_lnaof #define inet_makeaddr __inet_makeaddr #define inet_neta __inet_neta #define inet_netof __inet_netof #define inet_network __inet_network #define inet_net_ntop __inet_net_ntop #define inet_net_pton __inet_net_pton #define inet_ntoa __inet_ntoa #define inet_pton __inet_pton #define inet_ntop __inet_ntop #define inet_nsap_addr __inet_nsap_addr #define inet_nsap_ntoa __inet_nsap_ntoa
If you have source for BIND, you can modify it as indicated in the diff below. It causes the global variable _dns_ttl_ to be set with the TTL of the most recent lookup. Then, when you compile Squid, the configure script will look for the _dns_ttl_ symbol in libresolv.a. If found, dnsserver will return the TTL value for every lookup.
This hack was contributed by Endre Balint Nagy.
diff -ru bind-4.9.4-orig/res/gethnamaddr.c bind-4.9.4/res/gethnamaddr.c --- bind-4.9.4-orig/res/gethnamaddr.c Mon Aug 5 02:31:35 1996 +++ bind-4.9.4/res/gethnamaddr.c Tue Aug 27 15:33:11 1996 @@ -133,6 +133,7 @@ } align; extern int h_errno; +int _dns_ttl_; #ifdef DEBUG static void @@ -223,6 +224,7 @@ host.h_addr_list = h_addr_ptrs; haveanswer = 0; had_error = 0; + _dns_ttl_ = -1; while (ancount-- > 0 && cp < eom && !had_error) { n = dn_expand(answer->buf, eom, cp, bp, buflen); if ((n < 0) || !(*name_ok)(bp)) { @@ -232,8 +234,11 @@ cp += n; /* name */ type = _getshort(cp); cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ + class = _getshort(cp); + cp += INT16SZ; /* class */ + if (qtype == T_A && type == T_A) + _dns_ttl_ = _getlong(cp); + cp += INT32SZ; /* TTL */ n = _getshort(cp); cp += INT16SZ; /* len */ if (class != C_IN) {
And here is a patch for BIND-8:
*** src/lib/irs/dns_ho.c.orig Tue May 26 21:55:51 1998 --- src/lib/irs/dns_ho.c Tue May 26 21:59:57 1998 *************** *** 87,92 **** --- 87,93 ---- #endif extern int h_errno; + int _dns_ttl_; /* Definitions. */ *************** *** 395,400 **** --- 396,402 ---- pvt->host.h_addr_list = pvt->h_addr_ptrs; haveanswer = 0; had_error = 0; + _dns_ttl_ = -1; while (ancount-- > 0 && cp < eom && !had_error) { n = dn_expand(ansbuf, eom, cp, bp, buflen); if ((n < 0) || !(*name_ok)(bp)) { *************** *** 404,411 **** cp += n; /* name */ type = ns_get16(cp); cp += INT16SZ; /* type */ ! class = ns_get16(cp); ! cp += INT16SZ + INT32SZ; /* class, TTL */ n = ns_get16(cp); cp += INT16SZ; /* len */ if (class != C_IN) { --- 406,416 ---- cp += n; /* name */ type = ns_get16(cp); cp += INT16SZ; /* type */ ! class = _getshort(cp); ! cp += INT16SZ; /* class */ ! if (qtype == T_A && type == T_A) ! _dns_ttl_ = _getlong(cp); ! cp += INT32SZ; /* TTL */ n = ns_get16(cp); cp += INT16SZ; /* len */ if (class != C_IN) {
cache_cf.c: In function `parseConfigFile': cache_cf.c:1353: yacc stack overflow before `token' ...
You may need to upgrade your gcc installation to a more recent version. Check your gcc version with
gcc -vIf it is earlier than 2.7.2, you might consider upgrading.
Alternatively, you can get pre-compiled Squid binaries for BSD/OS 2.1 at the BSD patches FTP site, patch U210-019.
The following error occurs on Solaris systems using gcc when the Solaris C compiler is not installed:
/usr/bin/rm -f libmiscutil.a /usr/bin/false r libmiscutil.a rfc1123.o rfc1738.o util.o ... make[1]: *** [libmiscutil.a] Error 255 make[1]: Leaving directory `/tmp/squid-1.1.11/lib' make: *** [all] Error 1Note on the second line the /usr/bin/false. This is supposed to be a path to the ar program. If configure cannot find ar on your system, then it substitues false.
To fix this you either need to:
Please check the page of platforms on which Squid is known to compile. Your problem might be listed there together with a solution. If it isn't listed there, mail us what you are trying, your Squid version, and the problems you encounter.
Warnings are usually not a big concern, and can be common with software designed to operate on multiple platforms. If you feel like fixing compile-time warnings, please do so and send us the patches.
by Doug Nazar
In order in compile squid, you need to have a reasonable facsimile of a Unix system installed. This includes bash, make, sed, emx, various file utilities and a few more. I've setup a TVFS drive that matches a Unix file system but this probably isn't strictly necessary.
I made a few modifications to the pristine EMX 0.9d install.
You will need to run scripts/convert.configure.to.os2 (in the Squid source distribution) to modify the configure script so that it can search for the various programs.
Next, you need to set a few environment variables (see EMX docs for meaning):
export EMXOPT="-h256 -c" export LDFLAGS="-Zexe -Zbin -s"
Now you are ready to configure squid:
./configure
Compile everything:
make
and finally, install:
make install
This will by default, install into /usr/local/squid. If you wish to install somewhere else, see the --prefix option for configure.
Now, don't forget to set EMXOPT before running squid each time. I recommend using the -Y and -N options.