文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Apache虚拟主机设定及简单切换。

Apache虚拟主机设定及简单切换。

时间:2007-04-09  来源:liu1084

NameVirtualHost 10.12.96.131:80 <VirtualHost 10.12.96.131:80>
    ServerName  marketfx.rakuten-sec.co.jp
    ServerAlias marketfx.rakuten-sec.co.jp
    ErrorLog logs/10.12.96.131-error_log
    CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/10.12.96.131.%Y%m%d 86400 540" combined
    DocumentRoot /usr/local/apache2/htdocs
    <Directory /usr/local/apache2/htdocs/test>
        Options Indexes FollowSymLinks MultiViews 
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
  NameVirtualHost 10.9.30.11:80
<VirtualHost 10.9.30.11:80>
    ServerName  locahost
    ServerAlias 10.9.30.11
    ErrorLog /usr/local/apache2/logs/10.12.96.131
    CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/10.12.96.131.%Y%m%d 86400 540" combined
    DocumentRoot /usr/local/apache2/htdocs
    <Directory /usr/local/apache2/htdocs/test>
        Options FollowSymlinks
        Order allow,deny
        Allow from all
    </Directory>
    RewriteEngine On
    #RewriteCond %{REMOTE_HOST}  ^10.*
    RewriteCond %{REMOTE_HOST}  !^10.11.31.131
    RewriteRule ^/(.*)$ /usr/local/apache2/htdocs/test/mente_daily.html [L]
</VirtualHost>
  NameVirtualHost 10.9.30.11:80
<VirtualHost 10.9.30.11:80>
    ServerName  locahost
    ServerAlias 10.9.30.11 
    ErrorLog /usr/local/apache2/logs/10.12.96.131
    CustomLog "|/usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/10.12.96.131.%Y%m%d 86400 540" combined
    DocumentRoot /usr/local/apache2/htdocs
    <Directory /usr/local/apache2/htdocs/test>
        Options FollowSymlinks
        Order allow,deny
        Allow from all
    </Directory>
    RewriteEngine On
    #RewriteCond %{REMOTE_HOST}  ^10.*
    RewriteCond %{REMOTE_HOST}  !^10.11.31.131
    RewriteRule ^/(.*)$ /usr/local/apache2/htdocs/test/mente_emergency.html [L]
</VirtualHost>
  切换脚本: #!/bin/sh
#This is used to Switch apache page for (daily/emergency/default)
Apache_dir="/usr/local/apache2";
BIN_dir="/usr/local/apache2/bin";
CONF_dir="/usr/local/apache2/conf";
Switch_default()
{
        echo "Now,Apache will switch default page..."
        sleep 2;
        mv $CONF_dir/httpd.conf $CONF_dir/httpd.conf.bak;
        cp $CONF_dir/extra/httpd.conf $CONF_dir/httpd.conf;
        $BIN_dir/apachectl restart;
}
Switch_e()
{
        echo "Now,Apache will switch emergency page...";
        sleep 2;
        mv $CONF_dir/httpd.conf $CONF_dir/httpd.confd.bak;
        cp $CONF_dir/extra/httpd.conf.mente_emergency $CONF_dir/httpd.conf;
        $BIN_dir/apachectl restart;
}
Switch_d()
{
        echo "Now,Apache will be switched daily page..."
        sleep 2;
        mv $CONF_dir/httpd.conf $CONF_dir/httpd.conf.bak;
        cp $CONF_dir/httpd.conf.mente_daily $CONF_dir/httpd.conf;
        $BIN_dir/apachectl restart;
}
        case "$1" in
                e)
                        Switch_e
                        Result_=$?;
        ;;
                d)switch daily;
                        Switch_d;
                        Result_=$?;
        ;;
                default) switch default;
                        Switch_default;
                        Result_=$?;
        ;;
        *)
                echo
                echo "Usge: switch_apache.sh [default | e | d]";
                echo
                echo "-------------switch-------------"
                echo "1) default:default page"
                echo "2) e:emergency page";
                echo "3) d:daily page";
                echo " --------------------------------";
                exit 1;
        esac
        if [ "$Result_" = "0" ]
        then
                echo "Switch is sucessful!";
        else
                mv $CONF_dir/httpd.conf.bak $CONF_dir/httpd.conf;
                $BIN_dir/apachectl restart;
                echo "Error:Not Switch";
        fi
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载