|
This is a how-to for setting up Apache2 with IP Virtual Hosts. In this
example i will be uing internal Class C network IP addressess 192-223
but there is little difference to using external Class D IP addresses
224–239. at the end of this how-to we want the following website addresses to work 192.168.0.25 - http://portal.fedora.directory.server 192.168.0.50 - http://mail.fedora.directory.server 192.168.0.75 - http://intranet.fedora.directory.server Name: Apache HomePage: http://www.apache.org/ Function: Webserver
1. Login as root  2. Run the following command ifconfig eth0:1 192.168.0.128 netmask 255.255.255.0 3. Then change directories to /etc/sysconfig/network-scripts cd /etc/sysconfig/network-scripts 4. Once there copy the ifcfg-eth0 file to ifcfg-eth0:1 cp ifcfg-eth0 ifcfg-eth0:1
 5. Now edit the file to suit your new ip address nano /etc/sysconfig/network-scripts/ifcfg-eth0:1
ifcfg-eth0:1:
DEVICE=eth0:1 BOOTPROTO=static BROADCAST=192.168.0.255 HWADDR=00:50:BA:74:0D:7C IPADDR=192.168.0.25 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes TYPE=Ethernet
|
 6. Now restart the networking service /etc/init.d/network restart 7. Once that is done go to another machine on the same network and try and ping the new ip address. Then do the same for every ip address you want to make, eth0:2, eth0:3, eth04, etc 8. now lets make a new virtual host root directory, change thier ownership & change thier permissions mkdir /var/www/portal mkdir /var/www/intranet mkdir /var/www/mail chown apache:apache /var/www/portal chown apache:apache /var/www/intranet chown apache:apache /var/www/mail chmod ug+rwx /var/www/portal chmod ug+rwx /var/www/intranet chmod ug+rwx /var/www/mail
 9. Now we need to add the following lines to the /etc/httpd/conf/httpd.conf
httpd.conf:
<VirtualHost 192.168.0.25:80> DocumentRoot /var/www/portal ServerName portal.fedora.directory.server <Directory "/var/www/portal/"> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost 192.168.0.50:80> DocumentRoot /var/www/mail ServerName mail.fedora.directory.server <Directory "/var/www/mail/"> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost 192.168.0.75:80> DocumentRoot /var/www/intranet ServerName intranet.fedora.directory.server <Directory "/var/www/intranet/"> allow from all Options +Indexes </Directory> </VirtualHost>
|
 10. Now we need to edit our DNS server cd /var/name/chroot/etc 11. edit the named.conf file found there and add the following to it
nano /var/name/chroot/etc/named.conf named.conf:
zone "0.168.192.in-addr.arpa" { type master; file "/var/named/192.168.0.rev"; }; zone "fedora.directory.server" { type master; file "/var/named/fedora.directory.server.hosts"; };
|

12. Change directories to /var/named/chroot/var/named/ cd /var/named/chroot/var/named/ 13. We need to make and edit a file called fedora.directory.server.hosts
nano /var/named/chroot/var/named/fedora.directory.server.hosts
fedora.directory.server.hosts.conf:
$ttl 38400 fedora.directory.server. IN SOA 127.0.0.1. paul.hotmail.com. ( 1143594232 10800 3600 604800 38400 ) fedora.directory.server. IN NS 127.0.0.1. intranet.fedora.directory.server. IN A 192.168.0.75 mail.fedora.directory.server. IN A 192.168.0.50 portal.fedora.directory.server. IN A 192.168.0.25
|
 14. We need to make and edit a file called 192.168.0.rev
nano /var/named/chroot/var/named/192.168.0.rev 192.168.0.rev:
$ttl 38400 0.168.192.in-addr.arpa. IN SOA 127.0.0.1. paul.hotmail.com. ( 1143594165 10800 3600 604800 38400 ) 0.168.192.in-addr.arpa. IN NS 127.0.0.1. 75.0.168.192.in-addr.arpa. IN PTR intranet.fedora.directory.server. 50.0.168.192.in-addr.arpa. IN PTR mail.fedora.directory.server. 25.0.168.192.in-addr.arpa. IN PTR portal.fedora.directory.server.
|

15. Now you can run three different websites on the same machine, you could even install three different content management systems on this machine.
BookMarking:
cell1
|
|
cell3 |
|
cell4
|
|
Trouble Shooting:
Go to the wiki page Go to the 'Contact Us ' Forum Go to the how-to's Support Forum
External Links:
http://www.siliconvalleyccie.com/linux-hn/dns-static.htm#_Toc92808689 |