Remove lfs-uefi.txt symlink
[linux_from_scratch_hints.git] / PREVIOUS_FORMAT / apache-dynamic-ip.txt
blob15e238014196a629ae50ae62c91b9efd83de24a2
1 TITLE:          Apache with a Dynamic IP
2 LFS VERSION:    any
3 AUTHOR:         Ian Chilton <ian@ichilton.co.uk>
5 SYNOPSIS:
6         How to get Apache virtual hosting working when you have a dynamic IP,
7         ie. a PPP connection.
9 HINT:
11 This document explains how to use Apache's virtual hosting when you have a
12 dynamic IP address such as a dialup account, ADSL or a cable modem.
14 I copied /usr/local/apache/conf/httpd.conf to
15 /usr/local/apache/conf/httpd.conf.template and added this to the bottom:
17 (Do NOT replace the "----REPLACE_THIS_WITH_DYNIP----" bits, they are
18 supposed to be typed in like that :)
21 ------------ [SNIP httpd.conf.template ] ------------
24 NameVirtualHost ----REPLACE_THIS_WITH_DYNIP----
26 <VirtualHost ----REPLACE_THIS_WITH_DYNIP---->
27    ServerName www.domain1.com
28    DocumentRoot "/wwwroot/domain1"
29    ErrorLog /var/log/http-domain1-error_log
30    CustomLog /var/log/http-domain1-access_log common
31 </VirtualHost>
33 <VirtualHost ----REPLACE_THIS_WITH_DYNIP---->
34    ServerName www.domain2.com
35    DocumentRoot "/wwwroot/domain2"
36    ErrorLog /var/log/http-domain2-error_log
37    CustomLog /var/log/http-domain2-access_log common
38 </VirtualHost>
41 ------------ [SNIP httpd.conf.template ] ------------
44 Then, the clever bit..
46 If you running from /etc/ppp/ip-up, use:
48 cat /usr/apache/conf/httpd.conf.template |
49    sed -e "s/----REPLACE_THIS_WITH_DYNIP----/$4/g" >
50    /usr/apache/conf/httpd.conf
52 /usr/local/apache/bin/apachectl restart
55 If not, use:
57 MYIP=$(/sbin/ifconfig|grep -1 ppp0|cut -s -d ' ' -f12|
58    grep addr|cut -d ':' -f2)
60 cat /usr/apache/conf/httpd.conf.template |
61    sed -e "s/----REPLACE_THIS_WITH_DYNIP----/$MYIP/g" > 
62    /usr/apache/conf/httpd.conf
64 /usr/local/apache/bin/apachectl restart
67 And that should be it !!
69 Just remember that in the future any changes you need to make are
70 made to httpd.conf.template, not httpd.conf and after changes
71 you need to run the sed statement which creates the httpd.conf.
72 (perhaps create a little script to do it for you).