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

  • 2020-05-09 19:40:29
  • OfStack

Chapter 6 builds and installs Squid
First, use tar to unzip the source code

tar zxvf squid-2.6.STABLE13.tar.gz

After unpacking, we get a directory called squid-2.6.STABLE13. Enter the directory

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_Cflags# Intel_Core_Solo.2FDuo

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

It is then set using 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 the env command to see if the setup was successful.

Then, we start the configure source code. Use the following command to install squid into 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 the corresponding parameter can be obtained by using./configure --help.
Notice that configure is preceded by 1./, which represents the current directory. This means the configure file under the current directory. If you want to execute a file 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, such as bin/run. Of course, the./bin/run effect is also 1.
Then we'll see the screen scroll down and a whole bunch of checking for... The words. 1 wait until the text below 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 enter the make compiled source code, which is again a one-line English tumble. Does it feel like being a hacker? What we need to do is continue to wait for the following text 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]#

The source code is then compiled. Then we run the make install installation and wait for the following prompts

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 one of the steps has a warning 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 in strict accordance with this article, there will be no errors in type 1. 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 at configure)

At this point, squid is compiled and installed. We can go to /usr/local/squid. There are already a lot of files in it.
[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: