vhost.sh 源代码,认真看哦
#!/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 源代码,认真看哦的更多相关文章
- 如何下载和编译Android4.0内核源代码goldfish(图像)
如何下载Android4.0源代码.请参阅我的博客文章中有(同样是图文教程): http://blog.csdn.net/flydream0/article/details/7036156 怎样编译A ...
- 怎样下载并编译Android4.0内核源代码goldfish(图文)
关于怎样下载Android4.0源代码,请查看我的博客内还有一篇文章(相同是图文教程): http://blog.csdn.net/flydream0/article/details/7036156 ...
- 解剖SQLSERVER 完结篇 关于Internals Viewer源代码
解剖SQLSERVER 完结篇 关于Internals Viewer源代码 大家可能都用过Internals Viewer这个软件 <查看SQLSERVER内部数据页面的小插件Internals ...
- Hadoop-env.sh[翻译]
说明: 某天 ,把hadoop-env.sh的注释看了看 , 感觉受益匪浅,于是想要写一篇告诉大家,文档是最靠谱的,鉴于我的水平有限,只能翻译大概,切勿吐槽,提建议请留言 摘要: 1.这个文件中只有J ...
- lcx源代码以及免杀的研究
之前和Random大神讨论了一下免杀的问题,他给出了一个比较不错的想法,使用debug版本发布可以过很多杀软.顺便看了下lcx的源码,发现其代码不算特别复杂,于是乎就在这分析一下. 报毒情况 因为使用 ...
- 解密随机数生成器(二)——从java源码看线性同余算法
Random Java中的Random类生成的是伪随机数,使用的是48-bit的种子,然后调用一个linear congruential formula线性同余方程(Donald Knuth的编程艺术 ...
- STL源代码剖析 读书总结
<<STL源代码剖析>> 侯捷著 非常早就买了这本书, 一直没看, 如今在实验室师兄代码的时候发现里面使用了大量泛型编程的内容, 让我有了先看看这本书的想法. 看之前我对于泛型 ...
- Dialog与FragmentDialog源代码分析
<世界守则> -UI一片 注形容自己用语言 android学习之路 转载请保留出处 by Qiao http://blog.csdn.net/qiaoidea/article/detail ...
- 20140603 对error.c 用于分析源代码
20140603 对error.c 用于分析源代码 继续看error.c该功能 买家现在将自己的代码和数据汇编例如,下面的: 1.#include <stdio.h> 2 #inc ...
随机推荐
- react学习笔记-01
1. HTML模板 Jsx是react的语法糖,最终会被编译成js语法.因此需要第三方库browser将jsx转换成js. 由于react 0.14版本之后,将react和react-dom拆分,所以 ...
- django urls.py更改遇到问题
Q:TypeError: view must be a callable or a list/tuple in the case of include() A:django 1.10版本改了写法了.首 ...
- 15个实用find命令
除了在一个目录结构下查找文件这种基本的操作,你还可以用find命令实现一些实用的操作,使你的命令行之旅更加简易. 本文将介绍15种无论是于新手还是老鸟都非常有用的Linux find命令. 1. 用文 ...
- java 中递归的实现 以及利用递归方法实现汉诺塔
今天说下java语言中比较常见的一种方法,递归方法. 递归的定义 简单来说递归的方法就是"自己调用自己",通过递归方法往往可以将一个大问题简单化,最终压缩到一个易于处理的程度.对于 ...
- this笔记
在js中,如果this在全局变量和函数中this指window,在在对象中至所挂载的这个对象.
- 浅谈position: absolute和position:relative
一.在此先说一下文档流的概念: 1,文档流定义: 百度百科定义:文档流是文档中可显示对象在排列时所占用的位置. 大多网友的理解:元素的位置由元素在 (X)HTML 中的位置决定.将窗体自上而下分成一行 ...
- Impala:新一代开源大数据分析引擎
Impala架构分析 Impala是Cloudera公司主导开发的新型查询系统,它提供SQL语义,能查询存储在Hadoop的HDFS和HBase中的PB级大数据.已有的Hive系统虽然也提供了SQL语 ...
- ManyToMany OrderBy
有A.B表和A_B中间表,A_B中间表只有A.B表的id,想让A中的bs以date列排序: @Entity @Table(name="A") public class A impl ...
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver问题
java.lang.ClassNotFoundException: com.mysql.jdbc.Driverat org.apache.catalina.loader.WebappClassLoad ...
- List container
//List容器 //List本质是一个双向链表 //构造函数 list<int>c0; //空链表 list<int>c1(3); //建一个含三个默认值是0的元素链表 li ...