varnish

varnish

部署使用varnish

运维 小白菜 发表了文章 0 个评论 1921 次浏览 2015-06-30 12:02 来自相关话题

节点:192.168.83.46 部署了LAMP+nagios监控系统开发80端口节点:192.168.83.47 部署varnish做46的缓存 部署varnish1. 设置 ...查看全部

节点:192.168.83.46 部署了LAMP+nagios监控系统开发80端口
节点:192.168.83.47 部署varnish做46的缓存

部署varnish

1. 设置好依赖目录


[root:~ Slave] # useradd -s /sbin/nologin varnish
[root:~ Slave] # mkdir /data/varnish/cache
[root:~ Slave] # mkdir /data/varnish/cache
[root:~ Slave] # mkdir /data/varnish/log
[root:~ Slave] # chown -R varnish:varnish /data/varnish/cache
[root:~ Slave] # chown -R varnish:varnish /data/varnish/log

Varnish的官方网址为: http://varnish-cache.org, 可以在这里下载最新版本的软件。在安装Varnish前需要安装PCRE库。如果没有安装该库,在Varnish2以上版本编译时,就会提示找不到PCRE库PCRE库则可以兼容正则表达式,所以必须先安装。下面介绍其安装过程。


2. pcre编译安装


[root:/opt/varnish Slave] # tar -zxvf pcre-8.00.tar.gz
[root:/opt/varnish Slave] # cd pcre-8.00
[root:/opt/varnish/pcre-8.00 Slave] # ./configure --prefix=/usr/local/pcre/
[root:/opt/varnish/pcre-8.00 Slave] # make && make install

3. varnish编译安装


[root:/opt/varnish Slave] # tar -zxvf varnish-2.0.6.tar.gz
[root:/opt/varnish Slave] # export PKG_CONFIG_PATH=/app/soft/varnish/lib/pkgconfig/ 这一行一定要有,不然在编译的时候会报错。这行用于指定Varnish 查找PCRE库的路径,如果PCRE安装到其他路径下,在这里指定即可,Varnish默认查找PCRE库的路径为usr/local/lib/pkgconfig。


[root:/opt/varnish/varnish-2.0.6 Slave] # ./configure -prefix=/app/soft/varnish -enable-debugging-symbols -enable-developer-warnings -enable-dependency-tracking
[root:/opt/varnish/varnish-2.0.6 Slave] # make
[root:/opt/varnish/varnish-2.0.6 Slave] # make install
[root:/opt/varnish/varnish-2.0.6 Slave] # cp redhat/varnish.initrc /etc/init.d/varnish
[root:/opt/varnish/varnish-2.0.6 Slave] # cp redhat/varnish.sysconfig /etc/sysconfig/varnish

4. 修改配置
进入varnish配置文件进行配置修改

[ root:/app/soft/varnish/etc/varnish Slave] # cd /app/soft/varnish/etc/varnish

[root:/app/soft/varnish/etc/varnish Slave] # vim default.vcl

启动和查看状态

[ root:/opt/varnish/varnish-2.0.6 Slave] # /app/soft/varnish/sbin/varnishd -f /app/soft/varnish/etc/varnish/default.vcl -s malloc,2G -T 127.0.0.1:2000 -a 0.0.0.0:8080
[root:/opt/varnish/varnish-2.0.6 Slave] # ps -ef |grep varnishd

Varnish启动运行信息 :


[root:/app/soft/varnish/bin Slave] # cd /app/soft/varnish/bin
[root:/app/soft/varnish/bin Slave] # /app/soft/varnish/bin/varnishlog
[root:/app/soft/varnish/bin Slave] # /app/soft/varnish/bin/varnishstat

杀掉varnish:


[root:/app/soft/varnish/bin Slave] # killall varnishd

部署使用varnish

运维 小白菜 发表了文章 0 个评论 1921 次浏览 2015-06-30 12:02 来自相关话题

节点:192.168.83.46 部署了LAMP+nagios监控系统开发80端口节点:192.168.83.47 部署varnish做46的缓存 部署varnish1. 设置 ...查看全部

节点:192.168.83.46 部署了LAMP+nagios监控系统开发80端口
节点:192.168.83.47 部署varnish做46的缓存

部署varnish

1. 设置好依赖目录


[root:~ Slave] # useradd -s /sbin/nologin varnish
[root:~ Slave] # mkdir /data/varnish/cache
[root:~ Slave] # mkdir /data/varnish/cache
[root:~ Slave] # mkdir /data/varnish/log
[root:~ Slave] # chown -R varnish:varnish /data/varnish/cache
[root:~ Slave] # chown -R varnish:varnish /data/varnish/log

Varnish的官方网址为: http://varnish-cache.org, 可以在这里下载最新版本的软件。在安装Varnish前需要安装PCRE库。如果没有安装该库,在Varnish2以上版本编译时,就会提示找不到PCRE库PCRE库则可以兼容正则表达式,所以必须先安装。下面介绍其安装过程。


2. pcre编译安装


[root:/opt/varnish Slave] # tar -zxvf pcre-8.00.tar.gz
[root:/opt/varnish Slave] # cd pcre-8.00
[root:/opt/varnish/pcre-8.00 Slave] # ./configure --prefix=/usr/local/pcre/
[root:/opt/varnish/pcre-8.00 Slave] # make && make install

3. varnish编译安装


[root:/opt/varnish Slave] # tar -zxvf varnish-2.0.6.tar.gz
[root:/opt/varnish Slave] # export PKG_CONFIG_PATH=/app/soft/varnish/lib/pkgconfig/ 这一行一定要有,不然在编译的时候会报错。这行用于指定Varnish 查找PCRE库的路径,如果PCRE安装到其他路径下,在这里指定即可,Varnish默认查找PCRE库的路径为usr/local/lib/pkgconfig。


[root:/opt/varnish/varnish-2.0.6 Slave] # ./configure -prefix=/app/soft/varnish -enable-debugging-symbols -enable-developer-warnings -enable-dependency-tracking
[root:/opt/varnish/varnish-2.0.6 Slave] # make
[root:/opt/varnish/varnish-2.0.6 Slave] # make install
[root:/opt/varnish/varnish-2.0.6 Slave] # cp redhat/varnish.initrc /etc/init.d/varnish
[root:/opt/varnish/varnish-2.0.6 Slave] # cp redhat/varnish.sysconfig /etc/sysconfig/varnish

4. 修改配置
进入varnish配置文件进行配置修改

[ root:/app/soft/varnish/etc/varnish Slave] # cd /app/soft/varnish/etc/varnish

[root:/app/soft/varnish/etc/varnish Slave] # vim default.vcl

启动和查看状态

[ root:/opt/varnish/varnish-2.0.6 Slave] # /app/soft/varnish/sbin/varnishd -f /app/soft/varnish/etc/varnish/default.vcl -s malloc,2G -T 127.0.0.1:2000 -a 0.0.0.0:8080
[root:/opt/varnish/varnish-2.0.6 Slave] # ps -ef |grep varnishd

Varnish启动运行信息 :


[root:/app/soft/varnish/bin Slave] # cd /app/soft/varnish/bin
[root:/app/soft/varnish/bin Slave] # /app/soft/varnish/bin/varnishlog
[root:/app/soft/varnish/bin Slave] # /app/soft/varnish/bin/varnishstat

杀掉varnish:


[root:/app/soft/varnish/bin Slave] # killall varnishd