无标题文档
wdCP系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用教程) wdCDN系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用手册)
wdOS系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用教程) wdDNS系统 (介绍,功能特性,运行环境,安装说明,演示,常见问题,使用手册)
注册 发贴 提问 回复-必看必看 wddns免费智能 DNS 开通 本地或虚拟机使 用wdcp 一键包在mysql编 译时"卡住"
【300G高防】双线 无视攻击 wdcp官方技术支持/服务 阿里云8折优惠券 无敌云 腾讯云优惠中,现注册更有260代金额券赠送
返回列表 发帖
提问三步曲: 提问先看教程/FAQ索引(wdcp,wdcp_v3,一键包)及搜索,会让你更快解决问题
1 提供详细,如系统版本,wdcp版本,软件版本等及错误的详细信息,贴上论坛或截图发论坛
2 做过哪些操作或改动设置等

温馨提示:信息不详,很可能会没人理你!论坛有教程说明的,也可能没人理!因为,你懂的
  1. #!/bin/bash
  2. #
  3. # Web Server Install Script
  4. # Created by wdlinux QQ:12571192
  5. # Url:http://www.wdlinux.cn
  6. # Last Updated 2010.11.19
  7. #


  8. PS_SERVER=`ps ax | grep nginx.conf | grep -v "grep"`
  9. if [[ $PS_SERVER ]];then
  10.         SERVER="nginx"
  11. else
  12.         SERVER="apache"
  13. fi

  14. conf_dir="/www/wdlinux/$SERVER/conf/vhost"
  15. log_dir="/www/wdlinux/$SERVER/logs"
  16. web_dir="/www/web"

  17. function dis_info {
  18.         clear
  19.         echo
  20.         echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  21.         echo "Add Virtual Host for wdlinux or lanmp,Written by wdlinux"
  22.         echo "---------------------------------------------------------------"
  23.         echo "Wdlinux is a customized version of CentOS based, for quick, easy to install web server system"
  24.         echo "lanmp is a tool to auto-compile & install lamp or lnmp on linux"
  25.         echo "This script is a tool add virtual host for wdlinux"
  26.         echo "For more information please visit http://www.wdlinux.cn"
  27.         echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  28.         echo
  29.         echo "The server is running $SERVER"
  30.         echo "----------------------------------------------------------------"
  31.         echo
  32. }
  33. dis_info;

  34. echo "Pleast input domain:"
  35. read -p "(Default or Example domain:www.wdlinux.cn):" domain
  36. if [[ $domain == "" ]];then
  37.         domain="www.wdlinux.cn"
  38. fi
  39. echo
  40. echo "domain:$domain"
  41. echo "-----------------------------------------"
  42. echo
  43. sdomain=${domain#www.}
  44. if [[ -f "$conf_dir/$domain.conf" ]];then
  45.         echo "$conf_dir/$domain.conf is exists!"
  46.         exit
  47. fi

  48. echo "Do you want to add more domain name? (y/n)"
  49. read more_domain
  50. if [[ $more_domain == "y" || $more_domain == "Y" ]];then
  51.         echo "Input domain name,example(bbs.wdlinux.cn blog.wdlinux.cn):"
  52.         read domain_a
  53.         domain_alias=${sdomain}" "${domain_a}
  54. else
  55.         domain_alias=$sdomain;
  56. fi
  57. echo
  58. echo "domain alias:$domain_alias"
  59. echo "-----------------------------------------"
  60. echo

  61. echo "Allow access_log? (y/n)"
  62. read access_log
  63. if [[ $access_log == "y" || $access_log == "Y" ]];then
  64.         nginx_log="log_format  $domain  '\$remote_addr - \$remote_user [\$time_local] \"\$request\" '
  65.                '\$status \$body_bytes_sent \"\$http_referer\" '
  66.                '\"\$http_user_agent\" \$http_x_forwarded_for';
  67.             access_log  logs/$domain.log  $domain;"
  68.         apache_log="    ErrorLog \"logs/$domain-error_log\"
  69.     CustomLog \"logs/$domain-access_log\" common"
  70.         echo
  71.         echo "access_log dir:"$log_dir/$domain.log
  72.         echo "------------------------------------------"
  73.         echo
  74. else
  75.         nginx_log="access_log off;"
  76.         apache_log=""
  77. fi

  78. echo "Do you want to add ftp Account? (y/n)"
  79. read ftp_account
  80. if [[ $ftp_account == "y" || $ftp_account == "Y" ]];then
  81.         read -p "ftp user name:" ftp_user
  82.         read -p "ftp user password:" ftp_pass
  83.         useradd -d $web_dir/$domain -s /sbin/nologin $ftp_user
  84.         echo "$ftp_pass" | passwd --stdin $ftp_user
  85.         chmod 755 $web_dir/$domain
  86.         echo
  87. else
  88.         echo "Create virtual host directory."
  89.         mkdir -p $web_dir/$domain
  90.         chown -R www.www $web_dir/$domain
  91. fi

  92. if [[ $SERVER == "nginx" ]];then
  93. cat > $conf_dir/$domain.conf<<eof
  94. server {
  95.         listen       80;
  96.         server_name $domain $domain_alias;
  97.         root $web_dir/$domain;
  98.         index  index.html index.php index.htm wdlinux.html;

  99.         location ~ \.php$ {
  100.             fastcgi_pass   127.0.0.1:9000;
  101.             fastcgi_index  index.php;
  102.             include fcgi.conf;
  103.         }
  104.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
  105.                 expires      1d;
  106.         }

  107.         location ~ .*\.(js|css)?$ {
  108.                 expires      12h;
  109.         }
  110.         $nginx_log
  111.     }
  112. eof
  113. else
  114. cat > $conf_dir/$domain.conf<<eof
  115. <VirtualHost *:80>
  116.     DocumentRoot "$web_dir/$domain"
  117.     ServerName $domain
  118.     ServerAlias $domain_alias
  119. $apache_log
  120. </VirtualHost>
  121. eof
  122. fi

  123. cat > $web_dir/$domain/index.html<<eof
  124. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  125. <html xmlns="http://www.w3.org/1999/xhtml">
  126. <head>
  127. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
  128. <title>test page</title>
  129. </head>

  130. <body>
  131. <div align="center">
  132.   <h1>test page of $domain  </h1>
  133.   <p>Create by vhost.sh of <a href="http://www.wdlinux.cn" target="_blank">www.wdlinux.cn</a> </p>
  134. </div>
  135. </body>
  136. </html>
  137. eof
  138. if [[ $ftp_account == "y" || $ftp_account == "Y" ]];then
  139.         chown $ftp_user $web_dir/$domain/index.html
  140. fi

  141. if [[ $SERVER == "nginx" ]];then
  142.         service nginxd restart
  143. else
  144.         service httpd restart
  145. fi

  146. echo
  147. echo
  148. echo
  149. echo "web site infomations:"
  150. echo "========================================"
  151. echo "domain list:$domain $domain_alias"
  152. echo "----------------------------------------"
  153. echo "website dir:$web_dir/$domain"
  154. echo "----------------------------------------"
  155. echo "conf file:$conf_dir/$domain.conf"
  156. echo "----------------------------------------"
  157. if [[ $access_log == "y" || $access_log == "Y" ]];then
  158.         echo "access_log:$log_dir/$domain.log"
  159.         echo "----------------------------------------"
  160. fi
  161. if [[ $ftp_account == "y" || $access_log == "Y" ]];then
  162.         echo "ftp user:$ftp_user password:$ftp_pass";
  163.         echo "----------------------------------------"
  164. fi
  165. echo "web site is OK"
  166. echo "For more information please visit http://www.wdlinux.cn"
  167. echo "========================================"
复制代码

TOP

楼主 我帮你下了http://www.wdlinux.cn/in_scripts/vhost.sh.txt 上面是这个文件的内容

TOP

返回列表