源码varnish安装

  1. 下载源码

    wget https://repo.varnish-cache.org/source/varnish-4.0.3.tar.gz

  2. 编译

    > tar -xzvf varnish-4.03.tar.gz

    进入源码目录

    > sh autogen.sh 

    >   export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

    >   ./configure --prefix=/usr/local/varnish --enable-dependency-tracking --enable-debugging-symbols --enable-developer-warnings

    > make && make

    * configure过程中可能会报找不到libpcre错误和libedit或readline错误。可能会需要单独安装pcre和readline。8.0以上版本的pcre好像不支持。

  3. 测试

       简单建立一个 default.vcl文件

      backend default{

         .host 127.0.0.1;

        .port  8080;

     }

    命令行执行 

    > ./varnishd -f ../etc/default.vcl -a 172.28.211.16:8080 -s malloc,1g -F -u varnish -g varnish

   *注意先建一个用户 varnish:varnish

   输出一下信息为成功

   

child (80451) Started

Child (80451) said Child starts


4. 服务配置

   >  cp varnish.initrc /etc/init.d/varnish

  >  cp varnish.sysconfig /etc/sysconfig/varnish

  > cp varnish_reload_vcl /usr/local/varnish/sbin/varnish_reload_vcl

  修改 /etc/init.d/varnish文件,主要是讲路径修改正确

  exec="/usr/local/varnish/sbin/varnishd"

  reload_exec="/usr/local/varnish/sbin/varnish_reload_vcl"

  prog="varnishd"

  config="/etc/sysconfig/varnish"

  lockfile="/var/lock/subsys/varnish"

  修改/etc/sysconfig/varnish文件

  VARNISH_VCL_CONF=/usr/local/varnish/etc/default.vcl #/etc/varnish/default.vcl

  VARNISH_SECRET_FILE=/usr/local/varnish/etc/secret #etc/varnish/secret 源码安装没有本文件,需要自己创建一个,随便填写key

      

   DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \

             -f ${VARNISH_VCL_CONF} \

             -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \

             -t ${VARNISH_TTL} \

             -p thread_pool_min=${VARNISH_MIN_THREADS} \

             -p thread_pool_max=${VARNISH_MAX_THREADS} \

             -p thread_pool_timeout=${VARNISH_THREAD_TIMEOUT} \

             -u varnish -g varnish \

             -S ${VARNISH_SECRET_FILE} \

             -s ${VARNISH_STORAGE}"


   > service varnish start


特别要说明的是如果你是64位linux不要使用yum的方式安装。



你可能感兴趣的:(varnish)