#!/bin/bash

echo "######welcome to install http server#########"
yum -y remove httpd*
yum -y install httpd*
IP=`ifconfig | grep -A 1 "^eth" | grep -o "addr:[0-9.]\{1,\}" | cut -d: -f2`
CONF=/etc/httpd/conf/httpd.conf
VHOST_CONF=/etc/httpd/vhost/vhost.conf
echo "ServerName $IP:80" >> $CONF
echo "Include vhost/vhost.conf" >> $CONF
mkdir -p /data/web
mkdir -p /data/web/test01
mkdir -p /data/web/test02
mkdir /etc/httpd/vhost
touch /etc/httpd/vhost/vhost.conf
cat >> $VHOST_CONF << EOF
Alias /test01 "/data/web/test01/"
<Directory "/data/web/test01">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Alias /test02 "/data/web/test02/"
<Directory "/data/web/test02">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
EOF
echo "this is test01 website welcome" >> /data/web/test01/index.html
echo "this is test02 website welcome" >> /data/web/test02/index.html
service httpd restart
iptables -F
setenforce 0