Squid安裝linux
官方地址:http://www.squid-cache.org/vim
[root@DaMoWang ~]# tar xf squid-4.2-20180806-r6d8f397.tar.gz [root@DaMoWang ~]# mv squid-4.2-20180806-r6d8f397 /opt/squid [root@DaMoWang ~]# cd /opt/squid
[roit@DaMoWang squid]# ./configure --prefix=/usr/local/squid \
--sysconfdir=/etc \
--enable-arp-acl \
--enable-linux-netfilter \
--enable-linux-tproxy \
--enable-async-io=100 \
--enable-err-language="Simplify_Chinese" \
--enable-underscore \
--enable-poll \
--enable-gnuregex && make && make install
[root@DaMoWang squid]# ln -s /usr/local/squid/sbin/* /usr/local/sbin/ [root@DaMoWang squid]# useradd -M -s /sbin/nologin squid [root@DaMoWang squid]# chown -R squid.squid /usr/local/squid/var/
編輯squid配置文件緩存
[root@DaMoWang squid]# vim /etc/squid.conf
# 添加 cache_effective_user squid 指定squid的程序用戶,用來設置初始化、運行時緩存的帳戶
# 添加 cache_effective_group squid 指定帳號的基本組
# 在這行上添加上面兩條內容 coredump_dir /usr/local/squid/var/cache/squid
# 把 cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256 的註釋去掉
[root@DaMoWang squid]# squid -k parse
先初始化緩存目錄,調用squid程序來啓動服務bash
[root@DaMoWang squid]# squid -z [root@DaMoWang squid]# squid [root@DaMoWang squid]# netstat -antup|grep squid tcp6 0 0 :::3128 :::* LISTEN 48923/(squid-1)
編寫squid啓動腳本,並使用chkconfig和service工具進行管理async
[root@DaMoWang squid]# vim /etc/init.d/squid #!/bin/bash #chkconfig: 2345 90 25 #config: /etc/squid.conf #pidfile: /usr/local/squid/var/run/squid.pid #Description: Squid - Internet Object Cache PID="/usr/local/squid/var/run/squid.pid" CONF="/etc/squid.conf" CMD="/usr/local/squid/sbin/squid" case "$1" in start) netstat -utpln | grep squid &>/dev/null if [ $? -eq 0 ] then echo "Squid is running" else $CMD fi ;; stop) $CMD -k kill &>/dev/null rm -rf $PID &>/dev/null ;; status) [ -f $PID ] &>/dev/null if [ $? -eq 0 ] then netstat -utpln | grep squid else echo "Squid is not running" fi ;; restart) $0 stop &>/dev/null echo "正在關閉Squid..." $0 start &>/dev/null echo "正在啓動Squid..." ;; reload) $CMD -k reconfigure ;; check) $CMD -k parse ;; *) echo "用法:{ start | stop | restart | reload | check | status}" ;; esac
賦予權限 , 添加到系統服務tcp
[root@DaMoWang squid]# chmod +x /etc/init.d/squid [root@DaMoWang squid]# chkconfig --add squid [root@DaMoWang squid]# chkconfig --level 35 squid on