下面是我在工作中經常建站所用到的腳本,首先把需要建的虛擬主機域名寫到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.laynepeng.cn】
服務器租用/服務器托管中國五強!虛擬主機域名注冊頂級提供商!15年品質保障!--億恩科技[ENKJ.COM]
|