4)配置hosts文件
#vi /etc/hosts
#
127.0.0.1 localhost
IP www.abc.com
5)配置/etc/init.d/squid
#!/bin/bash
# squid This shell script takes care of starting and stopping
# Squid Internet Object Cache
#
# chkconfig: - 90 25
# description: Squid - Internet Object Cache. Internet object caching is \
# a way to store requested Internet objects (i.e., data available \
# via the HTTP, FTP, and gopher protocols) on a system closer to the \
# requesting site than to the source. Web browsers can then use the \
# local Squid cache as a proxy HTTP server, reducing access time as \
# well as bandwidth consumption.
# pidfile: /home/squid/logs/squid.pid
# config: /usr/local/squid/etc/squid.conf
PATH=/usr/bin:/sbin:/bin:/usr/sbin
export PATH
# check if the squid conf file is present
[ -f /usr/local/squid/etc/squid.conf ] || exit 0
# don't raise an error if the config file is incomplete
# set defaults instead:
SQUID_OPTS=${SQUID_OPTS:-"-D"}
SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
# determine the name of the squid binary
[ -f /usr/local/squid/sbin/squid ] && SQUID=/usr/local/squid/sbin/squid
[ -z "$SQUID" ] && exit 0
prog="$SQUID"
# determine which one is the cache_swap directory
CACHE_SWAP=`sed -e 's/#.*//g' /usr/local/squid/etc/squid.conf | \
grep cache_dir | awk '{ print $3 }'`
[ -z "$CACHE_SWAP" ] && CACHE_SWAP=/export/home/squid/cache
RETVAL=0
start() {
for adir in $CACHE_SWAP; do
if [ ! -d $adir/00 ]; then
echo -n "init_cache_dir $adir... "
$SQUID -z -F -D 2>/dev/null
fi
done
echo -n $"Starting $prog: "
$SQUID $SQUID_OPTS 2> /dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
timeout=0;
while : ; do
[ ! -f /export/home/squid/logs/squid.pid ] || break
if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
RETVAL=1
break
fi
sleep 1 && echo -n "."
timeout=$((timeout+1))
done
fi
[ $RETVAL -eq 0 ] && echo "OK"
[ $RETVAL -ne 0 ] && echo "Failed"
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
$SQUID -k check >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
$SQUID -k shutdown &
timeout=0
while : ; do
[ -f /export/home/squid/logs/squid.pid ] || break
if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
echo
return 1
fi
sleep 2 && echo -n "."
timeout=$((timeout+2))
done
echo "OK"
echo
else
echo "Failed"
echo
fi
return $RETVAL
}
reload() {
$SQUID $SQUID_OPTS -k reconfigure
}
restart() {
stop
start
}
rhstatus() {
status $SQUID
$SQUID -k check
}
probe() {
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
status)
rhstatus
;;
probe)
exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|reload|restart}"
exit 1
esac
exit $?
静态页面:http://www.qqread.com/solaris/l320693.html
相关图文阅读
频道图文推荐
健 康 咨 询
时 尚 咨 询
相关专题
- 电脑配置手册 (8416篇文章)
- 服务器配置专栏 (10992篇文章)
- Solaris 10简单教程 (614篇文章)
- 网络游戏攻略 (4418篇文章)
- Solaris基础知识入门 (4653篇文章)
- 代理技术在Linux方面的应用 (85篇文章)
- 代理服务器软件 (100篇文章)
- Solaris配置 (53篇文章)
- 其他服务器 (181篇文章)
- Squid配置方法 (14篇文章)
- 新手学堂:Solaris SSH的配置和管理介绍 (0次浏览)
- Solaris工作站常用下载工具推荐(下) (0次浏览)
- Solaris工作站常用下载工具推荐(上) (0次浏览)
- Solaris 10下DNS服务器安全攻略 (0次浏览)
- 为Solaris服务器配置开源安全工具(下) (0次浏览)
- 为Solaris服务器配置开源安全工具(上) (0次浏览)
- 在Solaris下使用USB存储设备 (0次浏览)
- Solaris 10 系统维护 (0次浏览)



