下面是我在工作中经常建站所用到的脚本,首先把需要建的虚拟主机域名写到test.txt中然后在开始写下面的脚本,此脚本是在nginx环境下用的
#!/bin/bash
for domain in `cat test.txt`
do
cat >> /usr/local/nginx/conf/vhost/host.conf << EOF或者用下句二者择其一
cat > /usr/local/nginx/conf/vhost/$domain.conf << EOF
server
{
listen 80;
server_namewww.$domain$domain;
index index.php index.html index.htm;
root /data0/web/$domain;
error_page 404 =http://www.$domain;
if (!-f \$request_filename){
set \$rule_0 1\$rule_0;
}
if (!-d \$request_filename){
set \$rule_0 2\$rule_0;
}
if (\$rule_0 = "21"){
rewrite ^/(.*)\?*$ /index.php?_route_=\$1 last;
}
if (\$host != 'www.$domain' ) {
rewrite ^/(.*)$http://www.$domain/\$1permanent;
}
location ~ .*\.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
}
EOF
done
亿恩科技地址(ADD):郑州市黄河路129号天一大厦608室 邮编(ZIP):450008 传真(FAX):0371-60123888
联系:亿恩小凡
QQ:89317007
电话:0371-63322206 本文出自:亿恩科技【www.enkj.com】
服务器租用/服务器托管中国五强!虚拟主机域名注册顶级提供商!15年品质保障!--亿恩科技[ENKJ.COM]
|