How to Compile Squid Proxy Server 4.7v on CentOS 7.6

Installation of Squid proxy server 4.7 on CentOS 7.6

Pre-requisites:

perl gcc autoconf automake make sudo wget libxml2-devel libcap-devel libtool-ltdl-devel

Download Link :

Click here to download squid proxy server version 4.7

Configure options:

--prefix=/usr --includedir=/usr/include --datadir=/usr/share --bindir=/usr/sbin   --libexecdir=/usr/lib/squid --localstatedir=/var --sysconfdir=/etc/squid

/etc/profile:

Squid PATH

export SQUID_HOME=/usr/bin/
export PATH=$SQUID_HOME:$PATH

Install the required packages for squid proxy server by executing the command with the following options.

[root@linuxhelp ~]# yum install  perl gcc autoconf automake make sudo wget libxml2-devel libcap-devel libtool-ltdl-devel  gcc-c++  -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.excellmedia.net
 * epel: fedora.cs.nctu.edu.tw
 * extras: centos.excellmedia.net
 * remi-php72: ftp.riken.jp
 * remi-safe: ftp.riken.jp
 * updates: centos.excellmedia.net
.
.
.
Dependency Installed:
  cpp.x86_64 0:4.8.5-36.el7_6.2   perl-Thread-Queue.noarch 0:3.02-2.el7   xz-devel.x86_64 0:5.2.2-1.el7   zlib-devel.x86_64 0:1.2.7-18.el7  

Updated:
  wget.x86_64 0:1.14-18.el7_6.1                                                                                                              

Dependency Updated:
  libgcc.x86_64 0:4.8.5-36.el7_6.2                                     libgomp.x86_64 0:4.8.5-36.el7_6.2  

Download the squid proxy server 4.7 version source code as follows.

[root@linuxhelp ~]# wget http://www.squid-cache.org/Versions/v4/squid-4.7-20190507-r2e17b0261.tar.gz
--2019-05-31 08:42:29--  http://www.squid-cache.org/Versions/v4/squid-4.7-20190507-r2e17b0261.tar.gz
Resolving www.squid-cache.org (www.squid-cache.org)... 166.78.139.188, 212.199.163.170, 77.93.254.178, ...
Connecting to www.squid-cache.org (www.squid-cache.org)|166.78.139.188|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5259952 (5.0M) [application/octet-stream]
Saving to: ‘squid-4.7-20190507-r2e17b0261.tar.gz’

100%[===================================================================================================>] 5,259,952   26.1MB/s   in 0.2s   

2019-05-31 08:42:44 (26.1 MB/s) - ‘squid-4.7-20190507-r2e17b0261.tar.gz’ saved [5259952/5259952]

List the contents to check the downloaded squid tar file.

[root@linuxhelp ~]# ll
total 5164
-rw-------. 1 root root    2097 Dec  9  2017 anaconda-ks.cfg
drwxr-xr-x. 2 root root       6 Dec 12  2017 Desktop
drwxr-xr-x. 2 root root       6 Dec 12  2017 Documents
drwxr-xr-x. 2 root root       6 Dec 12  2017 Downloads
-rw-r--r--. 1 root root    2128 Dec 12  2017 initial-setup-ks.cfg
drwxr-xr-x. 2 root root       6 Dec 12  2017 Music
drwxr-xr-x. 2 root root       6 Dec 12  2017 Pictures
drwxr-xr-x. 2 root root       6 Dec 12  2017 Public
-rw-r--r--  1 root root   16004 Mar  8 13:10 remi-release-7.rpm
-rw-r--r--  1 root root 5259952 May  7 15:38 squid-4.7-20190507-r2e17b0261.tar.gz
drwxr-xr-x. 2 root root       6 Dec 12  2017 Templates
drwxr-xr-x. 2 root root       6 Dec 12  2017 Videos

Extract the tar file of squid proxy server 4.7 version as follows.

[root@linuxhelp ~]# tar xvzf squid-4.7-20190507-r2e17b0261.tar.gz 
squid-4.7-20190507-r2e17b0261/
squid-4.7-20190507-r2e17b0261/ChangeLog
squid-4.7-20190507-r2e17b0261/contrib/
squid-4.7-20190507-r2e17b0261/contrib/user-agents.pl
squid-4.7-20190507-r2e17b0261/contrib/Makefile.in
squid-4.7-20190507-r2e17b0261/contrib/url-normalizer.pl
squid-4.7-20190507-r2e17b0261/contrib/solaris/
squid-4.7-20190507-r2e17b0261/contrib/solaris/solaris-krb5-include.patch
squid-4.7-20190507-r2e17b0261/contrib/nextstep/
squid-4.7-20190507-r2e17b0261/contrib/nextstep/Makefile
squid-4.7-20190507-r2e17b0261/contrib/nextstep/post_install
squid-4.7-20190507-r2e17b0261/contrib/nextstep/Squid.pkg.README
squid-4.7-20190507-r2e17b0261/contrib/nextstep/makepkg
squid-4.7-20190507-r2e17b0261/contrib/nextstep/Makefile.real
squid-4.7-20190507-r2e17b0261/contrib/nextstep/info.in
squid-4.7-20190507-r2e17b0261/contrib/nextstep/pre_install
.
.
.
.
squid-4.7-20190507-r2e17b0261/src/XactionInitiator.h
squid-4.7-20190507-r2e17b0261/src/HttpHdrSc.cc
squid-4.7-20190507-r2e17b0261/src/HttpRequest.h
squid-4.7-20190507-r2e17b0261/src/StoreMeta.cc
squid-4.7-20190507-r2e17b0261/src/swap_log_op.cc
squid-4.7-20190507-r2e17b0261/src/HttpHdrContRange.cc
squid-4.7-20190507-r2e17b0261/src/CommonPool.h
squid-4.7-20190507-r2e17b0261/aclocal.m4
squid-4.7-20190507-r2e17b0261/QUICKSTART

List the contents to check the extracted directory of squid proxy server.

[root@linuxhelp ~]# ll
total 5168
-rw-------.  1 root  root     2097 Dec  9  2017 anaconda-ks.cfg
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Desktop
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Documents
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Downloads
-rw-r--r--.  1 root  root     2128 Dec 12  2017 initial-setup-ks.cfg
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Music
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Pictures
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Public
-rw-r--r--   1 root  root    16004 Mar  8 13:10 remi-release-7.rpm
drwxr-xr-x  16 user1 user1    4096 May  7 15:05 squid-4.7-20190507-r2e17b0261
-rw-r--r--   1 root  root  5259952 May  7 15:38 squid-4.7-20190507-r2e17b0261.tar.gz
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Templates
drwxr-xr-x.  2 root  root        6 Dec 12  2017 Videos

Change the directory to squid to install the server into CentOS 7.6.

 [root@linuxhelp ~]# cd squid-4.7-20190507-r2e17b0261/

List the contents to view the extracted files of squid directory.

 [root@linuxhelp squid-4.7-20190507-r2e17b0261]# ll
total 2460
drwxr-xr-x  2 user1 user1     233 May  7 14:50 acinclude
-rw-r--r--  1 user1 user1  407106 May  7 13:44 aclocal.m4
-rwxr-xr-x  1 user1 user1    4530 May  6 19:23 bootstrap.sh
drwxr-xr-x  2 user1 user1     143 May  7 14:50 cfgaux
-rw-r--r--  1 user1 user1  306258 May  6 19:23 ChangeLog
drwxr-xr-x  3 user1 user1    4096 May  7 14:50 compat
-rwxr-xr-x  1 user1 user1 1373001 May  7 13:45 configure
-rw-r--r--  1 user1 user1  137271 May  7 13:44 configure.ac
drwxr-xr-x  4 user1 user1     162 May  7 15:05 contrib
-rw-r--r--  1 user1 user1   19394 May  6 19:23 CONTRIBUTORS
-rw-r--r--  1 user1 user1   18092 May  6 19:23 COPYING
-rw-r--r--  1 user1 user1   87895 May  6 19:23 CREDITS
drwxr-xr-x  4 user1 user1     106 May  7 15:05 doc
drwxr-xr-x 48 user1 user1    4096 May  7 15:05 errors
drwxr-xr-x  3 user1 user1      87 May  7 14:50 icons
drwxr-xr-x  2 user1 user1    4096 May  7 15:05 include
-rw-r--r--  1 user1 user1     805 May  6 19:23 INSTALL
drwxr-xr-x  9 user1 user1    4096 May  7 14:50 lib
drwxr-xr-x  5 user1 user1    4096 May  7 14:50 libltdl
-rw-r--r--  1 user1 user1    1574 May  6 19:23 Makefile.am
-rw-r--r--  1 user1 user1   33273 May  7 13:45 Makefile.in
-rw-r--r--  1 user1 user1    2581 May  6 19:23 po4a.conf
-rw-r--r--  1 user1 user1    3818 May  6 19:23 QUICKSTART
-rw-r--r--  1 user1 user1    1513 May  6 19:23 README
-rw-r--r--  1 user1 user1   30670 May  7 15:05 RELEASENOTES.html
drwxr-xr-x  2 user1 user1    4096 May  7 14:50 scripts
-rw-r--r--  1 user1 user1    4659 May  7 13:45 SPONSORS
drwxr-xr-x 34 user1 user1   12288 May  7 15:05 src
drwxr-xr-x  3 user1 user1    4096 May  7 15:05 test-suite
drwxr-xr-x  8 user1 user1    4096 May  7 15:05 tools

Run the configure command to check the dependencies and compilers that are required to install the squid proxy server onto the system with the below-given commands.

[root@linuxhelp squid-4.7-20190507-r2e17b0261]# ./configure --prefix=/usr --includedir=/usr/include --datadir=/usr/share --bindir=/usr/sbin   --libexecdir=/usr/lib/squid --localstatedir=/var --sysconfdir=/etc/squid
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether UID '0' is supported by ustar format... yes
checking whether GID '0' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking whether to enable maintainer-specific portions of Makefiles... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
.
.
.
.
checking for opendir... yes
checking for readdir... yes
checking for strlcat... no
checking for strlcpy... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands

Run the make to built the software by executing the tasks that are defined inside the make file.

[root@linuxhelp squid-4.7-20190507-r2e17b0261]# make 
Making all in compat
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/compat'
depbase=`echo assert.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE=\"/etc/squid/squid.conf\" -DDEFAULT_SQUID_DATA_DIR=\"/usr/share\" -DDEFAULT_SQUID_CONFIG_DIR=\"/etc/squid\"   -I.. -I../include -I../lib -I../src -I../include    -I/usr/include/libxml2   -Wall -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Woverloaded-virtual -Werror -Wno-deprecated-register -pipe -D_REENTRANT -I/usr/include/libxml2   -g -O2 -march=native -std=c++11 -MT assert.lo -MD -MP -MF $depbase.Tpo -c -o assert.lo assert.cc &&\
mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  g++ -DHAVE_CONFIG_H -DDEFAULT_CONFIG_FILE=\"/etc/squid/squid.conf\" -DDEFAULT_SQUID_DATA_DIR=\"/usr/share\" -DDEFAULT_SQUID_CONFIG_DIR=\"/etc/squid\" -I.. -I../include -I../lib -I../src -I../include -I/usr/include/libxml2 -Wall -Wpointer-arith -Wwrite-strings -Wcomments -Wshadow -Woverloaded-virtual -Werror -Wno-deprecated-register -pipe -D_REENTRANT -I/usr/include/libxml2 -g -O2 -march=native -std=c++11 -MT assert.lo -MD -MP -MF .deps/assert.Tpo -c assert.cc  -fPIC -DPIC -o .libs/assert.o
.
.
.
.
Making all in test-suite
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/test-suite'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261/test-suite'
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261'

Run the make install to install the software that we have built using make.

[root@linuxhelp squid-4.7-20190507-r2e17b0261]# make install
Making install in compat
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/compat'
make[2]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/compat'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261/compat'
make[1]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261/compat'
Making install in lib
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/lib'
Making all in libTrie
make[2]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/lib/libTrie'
Making all in .
make[3]: Entering directory `/root/squid-4.7-20190507-r2e17b0261/lib/libTrie'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261/lib/libTrie'
Making all in test
.
.
.
.
make[1]: Entering directory `/root/squid-4.7-20190507-r2e17b0261'
make[2]: Entering directory `/root/squid-4.7-20190507-r2e17b0261'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261'
make[1]: Leaving directory `/root/squid-4.7-20190507-r2e17b0261'

check the version of squid proxy server

[root@linuxhelp squid-4.7-20190507-r2e17b0261]# squid --version
Squid Cache: Version 4.7-20190507-r2e17b0261
Service Name: squid
configure options:  '--prefix=/usr' '--includedir=/usr/include' '--datadir=/usr/share' '--bindir=/usr/sbin' '--libexecdir=/usr/lib/squid' '--localstatedir=/var' '--sysconfdir=/etc/squid'

With this, the installation of squid proxy server 4.7 from source code comes to end.

Comment
hailsonferreira
Jul 21 2021
I could start squid service after reboot the server but the service enter in failed state, someone can help me?
leagueofwhy
Jun 25 2019
I cannot use " systemctl start squid ", it says Failed to start squid.service: Unit not found.
Add a comment
FAQ
Q
What does Xff mean in squid proxy server?
A
In squid proxy server,X-forwarded for is a http header which identifies the client's Ip address ,originates and connects to the web server through an HTTP proxy or load balancer.
Q
What happens when a client connects to the squid proxy server?
A
In squid proxy server,when a client connects to the proxy server ,requesting some service such as file,connection,web page or other resource available from the different server.
Q
What does web proxy mean in Squid?
A
In squid,a proxy server acts as an intermediatory for the requests it gets from clients seeking resources from other servers.
Q
What does caching mean in squid proxy server?
A
In squid Proxy server,caching is a technology where it temporarily stores the web documents,web pages,images and other types of web multimedia to reduce server lag.
Q
What is reverse proxy in squid?
A
Reverse proxy makes squid to host multipe sites with single ip