Build your own CDN of vi with DNSPod and Squid and install Squid

  • 2020-05-06 12:11:27
  • OfStack

Chapter 6 compiles and installs Squid
Start by unzipping

from the source code zip using tar

tar zxvf squid-2.6.STABLE13.tar.gz

After unzipping, we get a directory called squid-2.6.STABLE13. Go to

cd squid-2.6.STABLE13

Before configure, we have to set cflags, so let's say CPU is intel core duo, cpu family 6,model 14. The corresponding optimization parameter

can be found by http:// gentoo-wiki.com/Safe_tar_Core_Solo.2FDuo

CHOST="i686-pc-linux-gnu"
CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

Then set

through the export command

export CHOST="i686-pc-linux-gnu"
export CFLAGS="-march=prescott -O2 -pipe -fomit-frame-pointer"
export CXXFLAGS="${CFLAGS}"

Once the setup is complete, we can check to see if the setup succeeded with the env command.

Then we start the configure source code. Use the following command to install squid in the /usr/local/squid directory.

./configure --prefix=/usr/local/squid --enable-follow-x-forwarded-for --enable-storeio=aufs,ufs --with-maxfd=65536 --with-pthreads --enable-dlmalloc --enable-poll --enable-stacktraces --enable-removal-policies=heap,lru --enable-delay-pools

The function of corresponding parameter can be obtained by using./configure --help.
Notice that configure is preceded by a./, which represents the current directory. This means the configure file under the current directory. If you want to execute the files in the current directory, you must add./. If you want to execute a file in a subdirectory in the current directory, you don't need to add, for example, bin/run. Of course./bin/run is the same.
Then we'll see the screen scroll down and a whole bunch of checking for... The words. Wait until the following text appears and stops, then configure is done.

config.status: creating tools/Makefile
config.status: creating include/autoconf.h
config.status: executing depfiles commands
[root@cnc squid-2.6.STABLE13]#

Then, we type in make to compile the source code, again a line of English rollouts. Does it feel like being a hacker? All we have to do is continue to wait for the text below to appear

make[2]: Leaving directory `/root/squid-2.6.STABLE13/tools'
make[1]: Leaving directory `/root/squid-2.6.STABLE13/tools'
make[1]: Entering directory `/root/squid-2.6.STABLE13'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/root/squid-2.6.STABLE13'
[root@cnc squid-2.6.STABLE13]#

So the source code is compiled. Then we run the make install installation and wait for the

prompt below

make[2]: Leaving directory `/root/squid-2.6.STABLE13'
make[1]: Leaving directory `/root/squid-2.6.STABLE13'
[root@cnc squid-2.6.STABLE13]#

Note here: if any of the steps are warned with an error or something like that, it's a compilation error, and you need to check exactly what steps went wrong and fix them. If compiled strictly according to this article, there are generally no errors. In addition, improper use of the cflags parameter can also cause compilation errors.
If a compilation error occurs, you must first make clean and then make again. (not if the error is in configure)

At this point, squid is compiled and installed. We can go to /usr/local/squid and have a look.
[root@cnc squid-2.6.STABLE13]# cd /usr/local/squid
[root@cnc squid]# ls -lh
total 72K
drwxr-xr-x 2 root root 4.0K Jul   7 02:27 bin
drwxr-xr-x 2 root root 4.0K Jul   7 02:27 etc
drwxr-xr-x 2 root root 4.0K Jul   7 02:27 libexec
drwx------ 2 root root   16K Jun 15 08:09 lost+found
drwxr-xr-x 3 root root 4.0K Jul   7 02:27 man
drwxr-xr-x 2 root root 4.0K Jul   7 02:25 sbin
drwxr-xr-x 4 root root 4.0K Jul   7 02:25 share
drwxr-xr-x 3 root root 4.0K Jul   7 02:25 var
[root@cnc squid]#

The next thing we need to do is configure squid.


Related articles: