FreeBSD
Prev 安装 squid Next

  • Proxy Server 安装

    我们现在选择的 Proxy Server 是使用 Squid ,而其具有以下的优势

    • 现今世界上网路中心的 Proxy 大多为 Unix 系统,所采用的 Server 也以 Squid 居多,同样使用 Squid ,设定他配比较容易。
    • 使用者众多,研究文献多,经验交流文章多
    • 功能强大,可以做出许多复杂的功能组合以及精密控制
    • 网路上关於 Squid 的各种分析器程式随手可得,有助於分析与研究。

  • 原始码下载

    Squid 最新的版本是 squid-2.5.STABLE7,所以我们就到官方网站里把最新的版本下载下来。把原始码下载回来后,放在 /tmp 底下,来作业。

    # cd /tmp
    # fetch http://ftp.nsysu.edu.tw/Unix/Proxy/squid/source/STABLE/squid-2.5.STABLE7.tar.gz

  • Squid 安装

    先建立一个新使用者 squid,所属群组也是 squid,安装 squid 时我们使用 squid 身分安装,并建立 Cache 目录结构。

    以 squid 身分安装 squid

    # cd /tmp
    # tar zxvf squid-2.5.STABLE7.tar.gz

    解压缩
    z:处理*.tar.gz的档案
    x:还原原先档案形式
    v:压缩或解压所时显示路径和档案名称
    f:指定档名
    
    # chown -R squid:squid squid-2.5.STABLE3

    变换 squid source 的拥有者及群组

    # su - squid  //切换成 squid
    $ cd /tmp/squid-2.5.STABLE7
    $ ./configure --prefix=/home/squid --enable-gnuregx \
    --enable-dlmalloc --enable-poll \
    --enable-err-language="Traditional_Chinese" \
    --enable-default-err-language=Traditional_Chinese \
    --enable-kill-parent-hack --enable-cache-digests \
    --disable-ident-lookups \
    --enable-removal-policies=heap \
    --enable-storeio=diskd,ufs \
    --enable-cachemgr-hostname="abc.ks.edu.tw" \
    --enable-snmp --disable-unlinkd --enable-truncate \
    --enable-stacktraces --disable-internal-dns
    
    设定安装环境,制作 Makefile, \ 接续断行指令

    叁数 说明

    --prefix=/home/squid
    指定安装目录。

    --enable-gnuregx
    Squid大量使用字串处理作各种判断,因此必须使用更好的 regex lib, 推荐使用 GNU 的 GNUregex lib,因其和 squid 相容,且在预设的 squid 原始码中即有,不需额外下载。

    --enable-dlmalloc
    Squid 为了快速反应 Client 端,在传达档案时是利用 RAM 中所建立的 硬碟索引表,因此常常会做 Memory Allocate & Free 的动作,所以 Memory Lib 的效能对 Proxy Server 整体效能影响非常大,而 DL-Malloc 是一种有效率的系统记忆体。

    --enable-poll
    用 poll() 取代预设的 select(),一般说来 poll 会比 select 表现更 完美,但因 poll 无法使用於某些平台,所以预设的的是 selsct,但仍 建议使用 poll。

    --enable-storeio=diskd,ufs
    使用 Diskd,这是新加入的 Disk I/O 处理动作,可以分别处理 Disk I/O 动作。详细说明: http://www.squid-cache.org/Doc/FAQ/FAQ-22.html

    --enable-default-err-language=Traditional_Chinese
    default Error Page Language

    --enable-err-language="Traditional_Chinese"
    选择 Error Page 的语言。

    --enable-kill-parent-hack Kill
    parent on shutdown,在关掉squid时,连同parent process一起关掉;当 Squid 挂点时,parent process(RunCache)会 自动重跑 Squid,加入此叁数,可完全停掉 Squid,不会自动重跑。

    --enable-cache-digests
    Use Cache Digests,使用 cache 摘要表,为 Proxy Server 间沟通的 方式,详细情形可叁考:
    http://www.squid-cache.org/Doc/FAQ/FAQ-16.html

    --disable-ident-lookups
    This allows you to remove code that performs Ident (RFC 931) lookups.

    --enable-removal-policies=heap
    使用各种 cache 的替代规则系统,取代标准的 LRU 规则系统。

    --enable-cachemgr-hostname="abc.ks.edu.tw"
    将 cachemgr.cgi 预设为此 host。

    --enable-snmp
    可以透过 snmp 利用 MRTG 来统计相关资料

    --disable-unlinkd
    Do not use unlinkd

    --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-stacktraces
    Enable automatic call backtrace on fatal errors

    --disable-internal-dns
    可以产生多个 DNS 的 child,增快解析网域名称的速度。

    $ ./configure --help|more可看各叁数英文说明
    $ make all编译
    $ make install安装

  • 修改核心支援 diskd

    若使用叁数 --enable-storeio=diskd,ufs,则必须在核心额外加入 options 才能够支援。

    # cd /sys/i386/conf
    # vi MYGENERIC
    加入

    options   SYSVSHM
    options   SYSVMSG
    options   SHMSEG=24
    options   SHMMNI=256
    options   SHMMAX=2097152
    options   SHMALL=4096
    options   MSGMNB=16384
    options   MSGMNI=40
    options   MSGSEG=2049
    options   MSGSSZ=64
    options   MSGTQL=1500
    
    # config MYGENERIC
    # cd ../compile/MYGENERIC
    # make depend all install
    # reboot

Prev Home Next
Cache 目录结构 UP 设定 squid