重新编译Squid笔记

发表于:2007-07-04来源:作者:点击数: 标签:
(一) 从http://www.squid-cache.org 下载Squid TAR安装包squid-2.5.STABLE9.tar.gz (二) unload Squid rpm -e squid (三) 编译Squid tar -zxvf squid-2.5.STABLE9.tar.gz cd squid-2.5.STABLE9 export CFLAGES='-02 -mcpu=pentium3' ./configure --prefix=/u

(一)
从http://www.squid-cache.org下载Squid TAR安装包squid-2.5.STABLE9.tar.gz
(二)
unload Squid
rpm -e squid
(三)
编译Squid
tar -zxvf squid-2.5.STABLE9.tar.gz
cd squid-2.5.STABLE9
export CFLAGES='-02 -mcpu=pentium3'
./configure --prefix=/usr/local/squid \

--sysconfdir=/etc/squid --enable-arp-acl --enable-cache-digests --enable-err-language="Traditional_Chinese" --enable-default-err-language="Traditional_Chinese" --enable-kill-parent-hack --enable-linux.netfilter --enable-snmp --enable-underscores --enable-gnuregex --enable-async-io=80 --enable-icmp --enable-poll --disable-ident-lookups
make && make install
(四)
设置/etc/squid/squid.conf
参考原RPM版本的squid.conf
只是Squid的log等按默认值处理,如下
http_port 172.16.3.2:3128
icp_port 3130
udp_outgoing_address 255.255.255.255
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 32 MB
cache_swap_low 90
cache_swap_high 95
maximum_object_size 8192 KB
ipcache_size 1024
ipcache_low 90
ipcache_high 95
fqdncache_size 1024
cache_dir ufs /usr/local/squid/var/cache1 3000 16 256
cache_dir ufs /usr/local/squid/var/cache2 4000 16 256
emulate_httpd_log on
client_netmask 255.255.255.255
dns_nameservers 202.96.134.133 202.96.128.166
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 563
acl CONNECT method CONNECT
http_aclearcase/" target="_blank" >ccess allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow all
http_reply_access allow all
icp_access allow all
cache_mgr root
cache_effective_user nobody
cache_effective_group nobody
visible_hostname ADSLserver
httpd_accel_host 172.16.3.2
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on
coredump_dir /usr/local/squid/var/cache
(五)
建立cache
mkdir /usr/local/squid/var/cache1
mkdir /usr/local/squid/var/cache2
chown -R nobody.nobody /usr/local/var
/usr/local/squid/sbin/squid -z
#正常情况显示2005/05/14 13:24:10| Creating Swap Directories
(六)
启动Squid
su nobody -c "/usr/local/squid/bin/RunCache &"
显示如下:
[root@ADSLserver sbin]# su nobody -c "/usr/local/squid/bin/RunCache &"
bash: /root/.bashrc: 拒絕不符權限的操作
[root@ADSLserver sbin]# Running: squid -sY >> /usr/local/squid/var/squid.out 2>&1
/usr/local/squid/bin/RunCache: line 20: /usr/local/squid/var/squid.out: 沒有此一檔案或目錄
/usr/local/squid/bin/RunCache: line 22: /usr/local/squid/var/squid.out: 沒有此一檔案或目錄
Running: squid -sY >> /usr/local/squid/var/squid.out 2>&1
解决:
touch /usr/local/squid/var/squid.out
chown nobody.nobody squid.out
再次运行RunCache
显示如下
[root@ADSLserver sbin]# /usr/local/squid/bin/RunCache: line 35: 30860 已經終止 squid -NsY $conf >>$logdir/squid.out 2>&1

[root@ADSLserver sbin]# Running: squid -sY >> /usr/local/squid/var/squid.out 2>&1
/usr/local/squid/bin/RunCache: line 35: 30872 已經終止
查看/usr/local/squid/var/logs/cache.log显示如下
2005/05/14 17:42:10| Starting Squid Cache version 2.5.STABLE9 for i686-pc-linux-gnu...
2005/05/14 17:42:10| Process ID 3602
2005/05/14 17:42:10| With 1024 file descriptors available
2005/05/14 17:42:10| Performing DNS Tests...
FATAL: ipcache_init: DNS name lookup tests failed.
Squid Cache (Version 2.5.STABLE9): Terminated abnormally.
CPU Usage: 0.010 seconds = 0.010 user + 0.000 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 277
这时您的Squid应该是正常了,只不过ADSL还没有拨号,所以为显示此错误,
adsl-start
之后正常
关于上面的说明:
启动squid: squid -D
squid的站点维护了一份很详细的FAQ,基本上你需要问的问题都有答案,比如你可以先用squid -NCd1来以debug模式启动,这样如果有错误会报出来,一般如果是ADSL拨号的,那么在没有拨号之前就启动squid的话是会出错的(FATAL: ipcache_init: DNS name lookup tests failed),因为squid启动时会去检查一些常用的DNS,但是这时候你并没有接入internet,自然就出错了,所以我们需要在启动的时候不检查DNS,这就需要用加上-D选项来启动squid
(七)
修改Sarg的配置
vi /usr/local/sarg/sarg.conf
只是修改如下
access_log /usr/local/squid/var/logs/access.log
#access_log /var/log/squid/access.log
(八)
全部正常,只是很多功能还要再作研究,只是现在可以上网了
其它如iptable和NAT的设置参照我之前写的文章

原文转自:http://www.ltesting.net