墨魚現形記--Squid安裝實錄
吳志凌
在它的官方網站中這麼說:Harris' Lament says, ``All the good ones are taken.",也就是說,它希望能像墨魚有八爪般將所有好的功能一網打盡!
這套Squid軟體是免費的提供原始檔提供下載使用的,您可以從 http://www.squid-cache.org/Versions/ 網址下載各種版本檔案。
當然,由於它目前只支援下列UNIX作業系統:
· Linux
· FreeBSD
· NetBSD
· BSDI
· OSF and Digital Unix
· IRIX
· SunOS/Solaris
· NeXTStep
· SCO Unix
· AIX
· HP-UX
· OS/2
所以在抓取墨魚之前,所謂工欲善其事,必先利其器,要記得先準備好一個已經安裝好UNIX作業系統的水族箱(機器啦),並且放置好過濾器,沙底等用品(像gcc之類的C編譯器,gzip之類的解壓縮軟體等等備用),當然你的機器必須網路通暢,然後就可以拿起捕捉墨魚的工具(像FTP,HTTP的工具皆可),準備好好打撈一番囉。
在本例中,我使用一台擁有兩顆Pentium III 800 CPU,1GB RAM,安裝Solaris8 x86的作業系統,哦!我很幸運的從下列網址抓取到最肥美的一隻:
http://www.squid-cache.org/Versions/v2/2.3/squid-2.3.STABLE4-src.tar.gz
也就是2.3 stable4 的目前最新版,將它從網中取出後儲存到之前準備的魚缸(工作目錄)中,再來就要開始宰殺(解壓縮)的動作:
gate9:[alex][3:35pm][Sat][Sep.23.00][~/Work]
[512]% gzip –d –c squid-2.3.STABLE4-src.tar.gz | tar xvf –
詳細畫面如下圖所示,你會看到它解開的所有檔案及路徑,大小等資訊。
解開的目錄之下所有檔案約4.3MB大小,等到解壓縮完成後,我們就使用下列指令改變目前工作目錄到squid-2.3.STABLE4/ 子目錄中﹔
gate9:[alex][3:35pm][Sat][Sep.23.00][~/Work]
[512]% cd squid-2.3.STABLE4
接著我們要先做編譯設定,由於squid 程式功能相當齊備,但是並不是所有的人都擁有相同的設備與作業環境,而且並不是所有的功能我們都需要,所有必須先設定此設定檔,然後才能根據這個設定作編譯的動作,所有的設定只要執行此目錄中的configure 程式加上所需參數即可,您可以執行./configure –help 得到所有可用的參數列表:
gate9:[alex][3:35pm][Sat][Sep.23.00][~/Work/squid-2.3.STABLE4]
[512]% ./configure --help
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
--cache-file=FILE cache test results in FILE
--help print this message
--no-create do not create output files
--quiet, --silent do not print `checking...' messages
--version print the version of autoconf that created configure
Directory and file names:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local/squid]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[same as prefix]
--bindir=DIR user executables in DIR [EPREFIX/bin]
--sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
--libexecdir=DIR program executables in DIR [EPREFIX/libexec]
--datadir=DIR read-only architecture-independent data in DIR
[PREFIX/share]
--sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data in DIR
[PREFIX/com]
--localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
--libdir=DIR object code libraries in DIR [EPREFIX/lib]
--includedir=DIR C header files in DIR [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
--infodir=DIR info documentation in DIR [PREFIX/info]
--mandir=DIR man documentation in DIR [PREFIX/man]
--srcdir=DIR find the sources in DIR [configure dir or ..]
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM
run sed PROGRAM on installed program names
Host type:
--build=BUILD configure for building on BUILD [BUILD=HOST]
--host=HOST configure for HOST [guessed]
--target=TARGET configure for TARGET [TARGET=HOST]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
--enable and --with options recognized:
--enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea
--enable-gnuregex Compile GNUregex
--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[=N_THREADS]
Do ASYNC disk I/O using threads.
N_THREADS is the number of worker threads
defaults to 16. See also src/squid.h for
some additional platform tuning
--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
--disable-wccp Disable Web Cache Coordination Protocol
--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-htcp 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)
--enable-poll Enable poll() instead of select(). Normally poll
is preferred over select, but configure knows poll
is broken on some platforms. If you think you are
smarter than the configure script, you may enable
poll with this option.
--disable-poll Disable the use of poll().
--disable-http-violations
This allows you to remove code which is known to
violate the HTTP protocol specification.
--enable-ipf-transparent
Enable Transparent Proxy support for systems
using IP-Filter network address redirection.
--enable-leakfinder
Enable Leak Finding code. Enabling this alone
does nothing; you also have to modify the source
code to use the leak finding functions. Probably
Useful for hackers only.
--disable-ident-lookups
This allows you to remove code that performs
Ident (RFC 931) lookups.
--disable-internal-dns This prevents Squid from directly sending and
receiving DNS messages, and instead enables the
old external 'dnsserver' processes.
--enable-truncate This uses truncate() instead of unlink() when
removing cache files. Truncate gives a little
performance improvement, but may cause problems
when used with async I/O. Truncate uses more
filesystem inodes than unlink..
--enable-underscores Squid by default rejects any host names with _
in their name to conform with internet standars.
If you disagree with this you may allow _ in
hostnames by using this switch, provided that
the resolver library on the host where Squid runs
does not reject _ in hostnames...
--enable-heap-replacement
This option allows you to use various cache
replacement algorithms, instead of the standard
LRU algorithm.
最簡單的方法當然就是全部使用其預設值,不過至少我們應指定安裝的路徑比較保險:
gate9:[alex][3:35pm][Sat][Sep.23.00][~/Work/squid-2.3.STABLE4]
[512]% ./configure --prefix=/usr/local/squid
如下圖所示,你會看到程式自動檢查系統所產生的一連串組態設定列表:
宰殺清潔乾淨後,當然就是要烹調了,若是編譯組態設定無誤,接著我們就可以編譯它,我使用目前UNIX上最常被使用的廚具(gcc 編譯器)〔gcc version 2.95.2 19991024 (release)〕編譯它:
gate9:[alex][3:59pm][Sat][Sep.23.00][~/Work/squid-2.3.STABLE4]
[516]% make all
編譯的時間較長一點,你這個時候可以去上個廁所,喝杯茶什麼的,什麼!已經好了?雙CPU的威力是頗不一樣的,哈!接著就要將這道菜放上主桌(安裝),要記的喔,不是在廚房權力無邊的主廚(在UNIX系統也就是root)是無法勝任這個工作的(至於如何由一般使用者變成root並不是這裡該教的,你可以參考相關UNIX的書籍資料,如果你就是由root管理者帳號登錄進來的,那就沒有這方面的困擾):
gate9:[alex][4:06pm][Sat][Sep.23.00][~/Work/squid-2.3.STABLE4]
[519]% make install
安裝完成後,不要高興的太早,菜是上桌了,但是還得有其他配料佐味才行呢!所以接下來我們要做複雜的設定動作,才能請賓客入桌。