Apache Virtural Host with dynamic ip address
1. Configure your apache reading the httpd.conf with external file.
Append these line into /etc/httpd/conf/httpd.conf
include /etc/httpd/conf/virtualhost
include /etc/httpd/conf/mydomainhost
2. Configure the update script running with cron
Put a script into /etc/cron.daily/rc.updatehttpd
###############################################
#!/bin/sh
HTTPADDR=”`ifconfig ppp0 |grep ‘inet addr’|awk ‘{print $2}’|sed -e ‘s/.*://’`”
HOSTFILE=”/etc/httpd/conf/mydomainhost”
echo “NameVirtualHost $HTTPADDR:80″ > /etc/httpd/conf/virtualhost
echo “
echo “DocumentRoot /var/www/html” >> $HOSTFILE
echo “ServerName http://www.mydomain.com”; >> $HOSTFILE
echo “
/etc/rc.d/init.d/httpd restart
##############################################
Note: The rc.updatehttpd must be 700 or 755