#!/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. ES CPU和磁盘IO升高

    问题 ES监控出现偶尔的波动,CPU和磁盘IO升高 有时候在凌晨,业务请求比较低,也没有慢查询,GC也比较正常,没有出现Full GC ES内部的merge segment会占用CPU和磁盘资源,怀疑 ...

  2. JAVA类与对象(课堂总结)

    一:"=="的不同含义 当"=="施加于原始数据类型变量时,是比较变量所保存的数据是否相等当"=="施加于引用类型变量时,是比较这两个变量是 ...

  3. Note_JavaWeb_SpringMVC_尚硅谷

    Spring MVC框架 官网文档 \spring-framework-4.2.6.RELEASE\docs\spring-framework-reference\htmlsingle ------- ...

  4. 查询被收录页面中的死链接 By SEO

    朋友说他的站挂了,想知道被收录的页面有多少是死链,于是我就想了一下流程,从Site获得收录数量当然是不精准的,不过也没有更好的地了,真实的收录只有搜索引擎数据库里面才有... 查询被收录页面的状态码, ...

  5. gitignore git提交忽略文件

    从网上找的git忽略文件挺前面的,现在记录下来,以备后用: tomsuite.xml **pom.xml.releaseBackup release.properties gen */seed.txt ...

  6. BOS物流管理系统-第八天

    BOS物流管理系统-第八天-权限系统设计-Shiro 回顾: 两大块业务:基础设置模块,业务派单模块. 两天:权限控制. 拦截器大的范围的.纯登录级别(认证级别)大颗粒的权限控制的一种技术. Shir ...

  7. HDU 1028 HDU Ignatius and the Princess III

    简单的钱币兑换问题,就是钱的种类多了一点,完全背包. #include<cstdio> #include<cstring> int main () { ]; memset(dp ...

  8. js实例--js滚动条缓慢滚动到顶部

    收集篇(已测)-- <html><head> <script type="text/javascript"> var currentPositi ...

  9. PAT 团体程序设计天梯赛-练习集 L1-020. 帅到没朋友

    原题  https://www.patest.cn/contests/gplt/L1-020 当芸芸众生忙着在朋友圈中发照片的时候,总有一些人因为太帅而没有朋友.本题就要求你找出那些帅到没有朋友的人. ...

  10. HDU1789Doing Homework again(贪心)

    Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of h ...