全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 2213|回复: 8
打印 上一主题 下一主题

[疑问] Varnish Cache for Directadmin 一键安装包

[复制链接]
跳转到指定楼层
1#
发表于 2014-11-24 11:28:30 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
适用于默认安装的DA环境(仅安装了Apache),已经使用nginx作为前端的不支持。
风险自负。

  1. #!/bin/bash

  2. # This is scripts install Varnish Cache for Directadmin.
  3. ### Build by Hoang_Service (ProfVPS.Com) ###

  4. RED='\033[01;31m'
  5. GREEN='\033[01;32m'
  6. RESET='\033[0m'

  7. #Clear Screen For Install
  8. clear

  9. echo -e "$GREEN----------------------------------------$RESET"
  10. echo -e "  $RED Varnish Cache (Ver 4.x) for Directadmin $RESET"
  11. echo -e "           Version Installer 1.0          "
  12. echo -e "     Build by Hoang_Service (ProfVPS.Com)  "
  13. echo -e "$GREEN----------------------------------------$RESET"

  14. #Check Directadmin Installed
  15. echo -ne "Checking Directadmin Installed..."
  16. if [ -e  "/usr/local/directadmin" ]; then
  17.         echo -e "[ $GREEN Directadmin Found $RESET ]"
  18. else
  19.         echo -e "[ $RED Directadmin Not Found.\n Exiting Install. $RESET ]"
  20.         exit
  21. fi

  22. #Removing Previous Varnish Cache
  23. yum -y remove varnish

  24. #Install Packages & Libraries
  25. rpm -Uvh https://dl.fedoraproject.org/pub/epel/6/x86_64/jemalloc-3.6.0-1.el6.x86_64.rpm
  26. rpm -Uvh https://repo.varnish-cache.org/redhat/varnish-4.0.el6.rpm
  27. yum -y install lynx

  28. #Install Varnish Cache
  29. yum -y install varnish

  30. #Config Varnish Cache
  31. cd /etc/varnish/
  32. ip=$(( lynx --dump cpanel.net/showip.cgi ) 2>&1 | sed "s/ //g")
  33. sed -i "s#host = "127.0.0.1"#host = "$ip"#g" ./default.vcl
  34. cd /etc/httpd/conf/
  35. sed -i 's#Listen 80#Listen 8080#g' ./httpd.conf
  36. cd extra
  37. sed -i "s#:80#:8080#g" ./httpd-vhosts.conf
  38. cp -p /usr/local/directadmin/data/templates/virtual_host2.conf  /usr/local/directadmin/data/templates/custom/virtual_host2.conf
  39. cp -p /usr/local/directadmin/data/templates/virtual_host2_sub.conf  /usr/local/directadmin/data/templates/custom/virtual_host2_sub.conf
  40. cp -p  /usr/local/directadmin/data/templates/redirect_virtual_host.conf  /usr/local/directadmin/data/templates/custom/redirect_virtual_host.conf
  41. cd /usr/local/directadmin/data/templates/custom
  42. sed -i 's/<VirtualHost |IP|:|PORT_80| |MULTI_IP|>/<VirtualHost 127.0.0.1:8080 |IP|:8080 |MULTI_IP|>/g' *
  43. cd
  44. wget http://www.stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
  45. tar xzf mod_rpaf-0.6.tar.gz
  46. cd mod_rpaf-0.6
  47. apxs -cia mod_rpaf-2.0.c
  48. cd
  49. ip=$(( lynx --dump cpanel.net/showip.cgi ) 2>&1 | sed "s/ //g")
  50. echo "<IfModule mod_rpaf-2.0.c>
  51. RPAFenable On
  52. RPAFsethostname On
  53. RPAFproxy_ips 127.0.0.1 $ip
  54. RPAFheader X-Forwarded-For
  55. </IfModule>" >> /etc/httpd/conf/extra/httpd-includes.conf
  56. echo "action=rewrite&value=httpd" >> /usr/local/directadmin/data/task.queue
  57. cd /etc/sysconfig/
  58. sed -i 's#VARNISH_LISTEN_PORT=6081#VARNISH_LISTEN_PORT=80#g' ./varnish

  59. #Start Varnish Cache
  60. service httpd restart
  61. service varnish start

  62. #Start When Reboot
  63. chkconfig varnish on

  64. echo -e "$GREEN---------------------------------------------------$RESET"
  65. echo -e "$GREEN      Varnish Cache Install Completed       $RESET"
  66. echo -e "You can monitor varnish cache with command:$GREEN varnishstat $RESET"
  67. echo -e "You can check log varnish cache with command:$GREEN varnishlog $RESET"
  68. echo -e "If have anything problem or bug. Please contact to yahoo: hoang_service"
  69. echo -e "$GREEN---------------------------------------------------$RESET"
复制代码
2#
发表于 2014-11-24 11:29:33 | 只看该作者
感谢分享,虽然现在还不需要,
3#
发表于 2014-11-24 12:45:00 | 只看该作者
mark一下

~~~~~~~~~~~~~
防水墙补丁
4#
发表于 2014-11-24 12:57:14 | 只看该作者
你这个只支持el6,el7不支持呢
5#
 楼主| 发表于 2014-11-24 12:59:02 | 只看该作者
loveminds 发表于 2014-11-24 12:57
你这个只支持el6,el7不支持呢

可以自己修改下文件,不难。
6#
发表于 2014-11-24 14:30:43 | 只看该作者
Varnish 我用来做反代,不错,嘿嘿
7#
发表于 2014-11-24 14:33:25 | 只看该作者
呼叫版主前来加分
8#
发表于 2014-11-25 14:39:31 | 只看该作者
风险自负。笔记一下
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-15 00:40 , Processed in 0.065757 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表