#!/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. C++设计模式-singleton单例模式_new

      class nocopyable { protected: nocopyable(){}; virtual ~nocopyable(){}; nocopyable(const nocopyable ...

  2. 4. printf 命令

    1. printf 命令的语法 printf format-string [arguments...] 参数说明: format-string: 为格式控制字符串 arguments: 为参数列表. ...

  3. 重读The C programming Lanuage 笔记一:类型转换

    首先说自动类型转换: 当一个运算符的几个操作数类型不同时,就需要吧他们转换位某种共同的类型.一般来说,自动转换把“较低”的类型转换为”较高“的类型.运算结果为较高的类型 以下是不严格的规则: 首先,如 ...

  4. 一个例子让你了解Java反射机制

    本文来自:blog.csdn.net/ljphhj JAVA反射机制: 通俗地说,反射机制就是可以把一个类,类的成员(函数,属性),当成一个对象来操作,希望读者能理解,也就是说,类,类的成员,我们在运 ...

  5. Hibernate5--课程笔记5

    关联关系映射: 关联关系,是使用最多的一种关系,非常重要.在内存中反映为实体关系,映射到DB中为主外键关系.实体间的关联,即对外键的维护.关联关系的发生,即对外键数据的改变. 外键:外面的主键,即,使 ...

  6. log4j2

    转载自 Blog of 天外的星星: http://www.cnblogs.com/leo-lsw/p/log4j2tutorial.html Log4j 2的好处就不和大家说了,如果你搜了2,说明你 ...

  7. Unity3d中Dictionary和KeyValuePair的使用

    using UnityEngine; using System.Collections; using System.Collections.Generic;public class test : Mo ...

  8. ZZNU 1988: Sn

    题目描述 给你两个数 n, p(0 < n,p <= 10^15); a1 = 1;  a2 = 1+2;  a3 = 1+2+3;  ... an = 1+2+3+...+n    Sn ...

  9. DHCP底层参考

    [原创翻译,水平有限] ISC DHCP支持802.1的以太网帧,令牌环和FDDI等网络.为了桥接物理层和DHCP层,它还必须实现IP和UDP协议帧. 这源于UNIX BSD socket 对未配置接 ...

  10. 菜鸟进阶——grunt

    为保证作者版权在此声明本文部分摘自 http://yujiangshui.com/grunt-basic-tutorial/   另,参考文章 http://www.tuicool.com/artic ...