• squid2.6 编译安装与配置


    1,设置“文件描述符”,并设置用户同时打开文件数量
    # vi /usr/include/bits/typesizes.h
    # vi /usr/include/linux/posix_types.h

    把里边的 #define __FD_SETSIZE 1024 改成 65536

    2,设置当前环境
    # ulimit -Hs 65536
    # ulimit -n 65536

    H参数是硬性限制,s是堆栈上限,n是文件描述符上限
    也可以永久修改这些限制,开机自动生效,配置如下:

    vi  /etc/security/limits.conf,添加以下内容
    *                soft   nofile          65536
    *                hard   nofile          65536

    3,下载编译squid
    可以到官方网站下载自己需要的版本,这里选用2.6版本


    ./configure --prefix=/usr/local/squid2.6 \
    --enable-gnuregex \
    --enable-icmp \
    --enable-linux-netfilter \
    --enable-default-err-language="Simplify_Chinese" \
    --enable-follow-x-forwarded-for \
    --enable-storeio=aufs,ufs \
    --enable-kill-parent-hack \
    --enable-cache-digests \
    --with-maxfd=65536 \
    --with-pthreads \
    --enable-dlmalloc \
    --enable-poll \
    --enable-stacktraces \
    --enable-removal-policies=heap,lru \
    --enable-delay-pools

    make
    makeinstall

    安装完毕后,可以到/usr/local/squid2.6目录去查看相关生成的文件,一般编译不出错,不会有啥问题。


    4,配置squid.conf配置文件
    配置文件如下:

    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
    acl Safe_ports port 80          # http
    acl Safe_ports port 21          # ftp
    acl Safe_ports port 443         # https
    acl Safe_ports port 70          # gopher
    acl Safe_ports port 210         # wais
    acl Safe_ports port 1025-65535  # unregistered ports
    acl Safe_ports port 280         # http-mgmt
    acl Safe_ports port 488         # gss-http
    acl Safe_ports port 591         # filemaker
    acl Safe_ports port 777         # multiling http
    acl CONNECT method CONNECT
    http_access allow manager localhost
    http_access deny manager
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports

    visible_hostname squid.abcd.cn

    http_access allow localhost
    http_access allow all


    access_log /var/log/squid/access.log squid
    cache_log /var/log/squid/cache.log
    cache_store_log /var/log/squid/store.log
    pid_filename /var/log/squid/squid.pid

    cache_effective_user nobody
    cache_effective_group nobody


    http_port 80 vhost vport


    cache_peer 10.10.10.1 parent 80     0 no-query no-digest originserver name=mail
    cache_peer_domain mail  mail.abcd.cn
    cache_peer_access mail allow all


    hierarchy_stoplist cgi-bin ?

    cache_mem 256 MB
    cache_swap_low 90
    cache_swap_high 95
    minimum_object_size 0 KB
    maximum_object_size 32768 KB
    maximum_object_size_in_memory 600 KB
    ipcache_size 1024
    ipcache_low 90
    ipcache_high 95
    cache_replacement_policy lru
    memory_replacement_policy lru
    cache_dir ufs /var/spool/squid 1600 16 256


    acl QUERY urlpath_regex cgi-bin \? \.js
    cache deny QUERY
    refresh_pattern ^ftp:          1440    20%     10080
    refresh_pattern ^gopher:       1440    0%      1440
    refresh_pattern .              0       20%     4320

    acl apache rep_header Server ^Apache
    broken_vary_encoding allow apache
    coredump_dir /var/spool/squid

    ##########################################################
    header_access Via deny all
    header_access Server deny all
    header_access X-Cache deny all
    header_access X-Cache-Lookup deny all
    httpd_suppress_version_string off


    # mkdir /var/log/squid //建立日志目录
    # chown nobody:nobody /var/log/squid //用户nobody用户和组来运行squid
    # mkdir /var/spool/squid //建立squid缓存目录
    # chown nobody:nobody /var/spool/squid //同样,给权限

    # /usr/local/squid2.6/sbin/squid -z //建立缓存目录
    # ls /var/spool/squid //查看是否建立成功


    5,开机自动运行squid
    vi /etc/rc.d/rc.local
    将以下内容添加最下边
    ulimit -Hs 65536
    ulimit -n 65536
    /usr/local/squid2.6/sbin/squid

    如果你添加ulimit到/etc/security/limits.conf配置文件了,就不需要在这里写了。


    更改配置文件后,重新加载:
    /usr/local/squid2.6/sbin/squid -k reconfigure

    停止squid程序:
    /usr/local/squid2.6/sbin/squid -k shutdown

    查看缓存信息:
    squidclient -p 80 mgr:info
    squidclient -p 80 mgr:mem

  • 相关阅读:
    Android NDK篇-C++语言之运算符重载 与多继承二义性
    TensorFlow 02(张量)
    记一次 .NET 某企业采购平台 崩溃分析
    SAP-QM-动态检验规则
    热门影视APP系统源码 可二开 后端+app+搭建教程
    软件测试/测试开发/人工智能丨​Python运算符解析,小白也能轻松get
    【C/C++】深入了解GCC编译器:命令使用及参数解释
    Mac下的平铺式桌面 - Yabai
    【Kafka系列】(一)Kafka入门
    MySQL下载步骤详解
  • 原文地址:https://blog.csdn.net/vempire/article/details/127728826