#!/bin/bash
#
# Web Server Install Script
# Created by wdlinux QQ:12571192
# Url:http://www.wdlinux.cn
# Last Updated 2010.11.19
# PS_SERVER=`ps ax | grep nginx.conf | grep -v "grep"`
if [[ $PS_SERVER ]];then
SERVER="nginx"
else
SERVER="apache"
fi conf_dir="/www/wdlinux/$SERVER/conf/vhost"
log_dir="/www/wdlinux/$SERVER/logs"
web_dir="/www/web" function dis_info {
clear
echo
echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo "Add Virtual Host for wdlinux or lanmp,Written by wdlinux"
echo "---------------------------------------------------------------"
echo "Wdlinux is a customized version of CentOS based, for quick, easy to install web server system"
echo "lanmp is a tool to auto-compile & install lamp or lnmp on linux"
echo "This script is a tool add virtual host for wdlinux"
echo "For more information please visit http://www.wdlinux.cn"
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo
echo "The server is running $SERVER"
echo "----------------------------------------------------------------"
echo
}
dis_info; echo "Pleast input domain:"
read -p "(Default or Example domain:www.wdlinux.cn):" domain
if [[ $domain == "" ]];then
domain="www.wdlinux.cn"
fi
echo
echo "domain:$domain"
echo "-----------------------------------------"
echo
sdomain=${domain#www.}
if [[ -f "$conf_dir/$domain.conf" ]];then
echo "$conf_dir/$domain.conf is exists!"
exit
fi echo "Do you want to add more domain name? (y/n)"
read more_domain
if [[ $more_domain == "y" || $more_domain == "Y" ]];then
echo "Input domain name,example(bbs.wdlinux.cn blog.wdlinux.cn):"
read domain_a
domain_alias=${sdomain}" "${domain_a}
else
domain_alias=$sdomain;
fi
echo
echo "domain alias:$domain_alias"
echo "-----------------------------------------"
echo echo "Allow access_log? (y/n)"
read access_log
if [[ $access_log == "y" || $access_log == "Y" ]];then
nginx_log="log_format $domain '\$remote_addr - \$remote_user [\$time_local] \"\$request\" '
'\$status \$body_bytes_sent \"\$http_referer\" '
'\"\$http_user_agent\" \$http_x_forwarded_for';
access_log logs/$domain.log $domain;"
apache_log=" ErrorLog \"logs/$domain-error_log\"
CustomLog \"logs/$domain-access_log\" common"
echo
echo "access_log dir:"$log_dir/$domain.log
echo "------------------------------------------"
echo
else
nginx_log="access_log off;"
apache_log=""
fi echo "Do you want to add ftp Account? (y/n)"
read ftp_account
if [[ $ftp_account == "y" || $ftp_account == "Y" ]];then
read -p "ftp user name:" ftp_user
read -p "ftp user password:" ftp_pass
useradd -d $web_dir/$domain -s /sbin/nologin $ftp_user
echo "$ftp_pass" | passwd --stdin $ftp_user
chmod 755 $web_dir/$domain
echo
else
echo "Create virtual host directory."
mkdir -p $web_dir/$domain
chown -R www.www $web_dir/$domain
fi if [[ $SERVER == "nginx" ]];then
cat > $conf_dir/$domain.conf<<eof
server {
listen 80;
server_name $domain $domain_alias;
root $web_dir/$domain;
index index.html index.php index.htm wdlinux.html; location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 1d;
} location ~ .*\.(js|css)?$ {
expires 12h;
}
$nginx_log
}
eof
else
cat > $conf_dir/$domain.conf<<eof
<VirtualHost *:80>
DocumentRoot "$web_dir/$domain"
ServerName $domain
ServerAlias $domain_alias
$apache_log
</VirtualHost>
eof
fi cat > $web_dir/$domain/index.html<<eof
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>test page</title>
</head> <body>
<div align="center">
<h1>test page of $domain </h1>
<p>Create by vhost.sh of <a href="http://www.wdlinux.cn" target="_blank">www.wdlinux.cn</a> </p>
</div>
</body>
</html>
eof
if [[ $ftp_account == "y" || $ftp_account == "Y" ]];then
chown $ftp_user $web_dir/$domain/index.html
fi if [[ $SERVER == "nginx" ]];then
service nginxd restart
else
service httpd restart
fi echo
echo
echo
echo "web site infomations:"
echo "========================================"
echo "domain list:$domain $domain_alias"
echo "----------------------------------------"
echo "website dir:$web_dir/$domain"
echo "----------------------------------------"
echo "conf file:$conf_dir/$domain.conf"
echo "----------------------------------------"
if [[ $access_log == "y" || $access_log == "Y" ]];then
echo "access_log:$log_dir/$domain.log"
echo "----------------------------------------"
fi
if [[ $ftp_account == "y" || $access_log == "Y" ]];then
echo "ftp user:$ftp_user password:$ftp_pass";
echo "----------------------------------------"
fi
echo "web site is OK"
echo "For more information please visit http://www.wdlinux.cn"
echo "========================================"

vhost.sh 源代码,认真看哦的更多相关文章

  1. 如何下载和编译Android4.0内核源代码goldfish(图像)

    如何下载Android4.0源代码.请参阅我的博客文章中有(同样是图文教程): http://blog.csdn.net/flydream0/article/details/7036156 怎样编译A ...

  2. 怎样下载并编译Android4.0内核源代码goldfish(图文)

    关于怎样下载Android4.0源代码,请查看我的博客内还有一篇文章(相同是图文教程): http://blog.csdn.net/flydream0/article/details/7036156 ...

  3. 解剖SQLSERVER 完结篇 关于Internals Viewer源代码

    解剖SQLSERVER 完结篇 关于Internals Viewer源代码 大家可能都用过Internals Viewer这个软件 <查看SQLSERVER内部数据页面的小插件Internals ...

  4. Hadoop-env.sh[翻译]

    说明: 某天 ,把hadoop-env.sh的注释看了看 , 感觉受益匪浅,于是想要写一篇告诉大家,文档是最靠谱的,鉴于我的水平有限,只能翻译大概,切勿吐槽,提建议请留言 摘要: 1.这个文件中只有J ...

  5. lcx源代码以及免杀的研究

    之前和Random大神讨论了一下免杀的问题,他给出了一个比较不错的想法,使用debug版本发布可以过很多杀软.顺便看了下lcx的源码,发现其代码不算特别复杂,于是乎就在这分析一下. 报毒情况 因为使用 ...

  6. 解密随机数生成器(二)——从java源码看线性同余算法

    Random Java中的Random类生成的是伪随机数,使用的是48-bit的种子,然后调用一个linear congruential formula线性同余方程(Donald Knuth的编程艺术 ...

  7. STL源代码剖析 读书总结

    <<STL源代码剖析>> 侯捷著 非常早就买了这本书, 一直没看, 如今在实验室师兄代码的时候发现里面使用了大量泛型编程的内容, 让我有了先看看这本书的想法. 看之前我对于泛型 ...

  8. Dialog与FragmentDialog源代码分析

    <世界守则> -UI一片 注形容自己用语言 android学习之路 转载请保留出处 by Qiao http://blog.csdn.net/qiaoidea/article/detail ...

  9. 20140603 对error.c 用于分析源代码

    20140603 对error.c 用于分析源代码 继续看error.c该功能 买家现在将自己的代码和数据汇编例如,下面的:   1.#include <stdio.h>   2 #inc ...

随机推荐

  1. Linux c 内存高速访问

    概述 要想高速利用内存就必须高效利用cpu cache,关于cpu cache这里就不多加讨论了,自己感兴趣可以google 而cpu访问内存的单位是cache line,因此高效利用cache li ...

  2. CSS3之动画Animation特效

    CSS3的出现 让我们通过css样式也能写出炫酷的特效 通过 Animation 这个属性 无需插件和jquery也可以轻松的完成简单的动画效果 DEMO: <!DOCTYPE html> ...

  3. PHP来实现文件上传

    文件php <?phpif ($_FILES["file"]["error"] > 0){ echo '错误: ' . $_FILES[" ...

  4. PHP使用正则表达式验证电话号码(手机和固定电话)

    这个还不错,很有用. tel='验证的电话号码'; $isMob="/^1[3-8]{1}[0-9]{9}$/";  $isTel="/^([0-9]{3,4}-)?[0 ...

  5. MongoDB高级查询用法大全

    转载 http://blog.163.com/lgh_2002/blog/static/440175262012052116455/ 详见官方的手册: http://www.mongodb.org/d ...

  6. hdu 1531 King

    首先吐槽一下这个题目的题意描述,我看了半天才明白. 下标全部都是乱标的!!!!出题者能不能规范一点下标的写法!!!! 差分约束系统 #include<cstdio> #include< ...

  7. C#指定某用户对某文夹件的访问权限

    using System.Security.AccessControl; //设置myFloder文件夹的iis访问权限                string userAccount = @&q ...

  8. POJ 1845 Sumdiv#质因数分解+二分

    题目链接:http://poj.org/problem?id=1845 关于质因数分解,模板见:http://www.cnblogs.com/atmacmer/p/5285810.html 二分法思想 ...

  9. Java 反射 Class类

    Java 反射 Class类 @author ixenos 摘要:Class类在反射中的地位.构造Class对象的三种方式.Class对象构造对应类型对象的三种方式 Class类在反射中的地位 位于j ...

  10. openwrt 串口无法登陆

    打印这个消息后串口无法进行交互 procd: - init complete - 主要问题是 /etc下inittab脚本中 ::sysinit:/etc/init.d/rcS S boot::shu ...