Grabber Softwares : Enhance Your Computing

Setting Up A Web Server

Red Hat includes Apache, a ready-to-use Web server

Linux comes with all the tools you will need to set up a Web, ftp and, telnet server. The daemons are installed by default and start up automatically at boot time. While the ftp and telnet servers will probably not need any further configuration, Apache, the worlds most popular Web browser that ships with Linux, is extremely powerful, and can be configured to handle any kind of environment from a lightly loaded Intranet to a commercial Internet Web server taking a 100,000 hits a day!

Configuring the Web server

Apache is set up and ready to run automatically at boot as soon as the installation is completed.

To check if it is working correctly, simply point your browser to the URL http://localhost. You should see Apache’s default It Worked page start up. You can now simply change the index.html file in the /home/httpd/html directory on your own and start publishing pages on your intranet. The default configuration file /etc/httpd/conf/httpd.conf is suitable for simple configurations, though you might want to edit it if you have an unusually heavy load, or wish to configure a different machine name, port, or address to send error messages.

There are two additional files in the conf directory. The access.conf file lets you define extra security parameters to your Web server, such as allowing only users from particular domains to browse. The srm.conf file allows you to tweak Apache’s behaviour to handle newer MIME types, and set users home directories. You will not normally need to edit these files, but it is a good idea to check them out for any settings peculiar to your setup.

Apache, however, lacks in one respect—an SSL implementation. But, there are free add-ins available which add this ability. Still, there are commercial servers such as Netscape’s Fastrack Web server which offer such functionality if that is what you require. Most sites will never have the need for secure transactions when used only over an intranet.

Web server for multiple interfaces

If you have a moderately large intranet environment, you may want to set up different websites for various departments or projects. For example, our own intranet has websites such as mail.cmil.com, reviews.cmil.com etc. Each of these websites lies on a single Linux server, configured to use multiple interfaces with independent host names and IP addresses (also called Virtual Domains).

The first step is to set up multiple interfaces to your ethernet card. The existing interface will be eth0, hence use the ifconfig command to add a new interface to it:
/sbin/ifconfig eth0:1 192.168.1.200

Now we have to add a route to the new interface: /sbin/route add -host 192.168.1.200 dev eth0:1

Make sure the 192.168.1.200 (or whatever you choose) is a reserved IP address and cannot by dynamically assigned by your DHCP server.

You can now ping the new IP address as any other address on the network.

Now edit your nameserver files to give this interface a suitable name (say reviews.cmil.com). If you are running a DNS on you machine you can configure it from there (read Configuring DHCP And DNS Services).

Change to the directory /var/named. Using the text editor, edit the file named.xxx.yyy.forward (where xxx.yyy is your domain name). Scroll down the list until you find the entry ws200 corresponding to the IP 192.168.1.200. Replace ws200 with whatever you want to name your interface, in this case reviews.

Restart named using the command /etc/rc.d/init.d/named restart.

You should be able to ping any the interface by name from any machine on your network.

The final step is to create a file to add the interface and route automatically at boot time. Create a file (say rc.virtual) in the /etc/rc.d directory and add the two lines to it. The first line of the script should be #!/bin/sh. Mark it executable (chmod +x rc.virtual), and edit the file rc.local in the same directory. At the last line of that file, add the line /etc/rc.d/rc.virtual. That will ensure that it is run automatically at boot. You can similarly add as many virtual domains as you wish.

If you are using a firewall, don’t forget to add the appropriate lines to secure the interface. In this case, you may want to restrict access to only a particular port.

Add the correct domain name to the virtual host tag and specify a document root path, which defines where you will be storing the HTML files for that host. The correct permissions on this directory are important. Make sure that it is world readable.

Configuring Apache for multiple domains

Once you have set up IP aliasing as described above, you have to configure Apache to work with the new domain.

The Apache configuration file allows you to configure virtual hosts to have their own document roots. At the bottom of the /etc/httpd/conf/httpd.conf file you will find a sample <VirtualHost domainname> tag.

Add the Serveradmin address, and the servername to report (the virtual interface name, not the actual machine name).

End the section with a </VirtualHost> tag, restart http using the command etc/rc.d/init.d/httpd restart. You can now browse the virtual domain name from any machine on your network.