Hack 42 Create an Emergency Web Server

 < Day Day Up > 

figs/expert.gif figs/hack42.gif

When the web server goes down, use Knoppix to pick up the slack .

On first glance, Knoppix may not seem like a distribution to use for web serving because of its colorful GUI, the desktop applications, and the games . But included in this huge bundle of software is the complete Apache 1.3 server and a large set of modules that give you many of the common tools you need to turn Knoppix into a replacement web server.

Before you set up Knoppix as a web server, make sure Knoppix has all the tools you need for your web site. Look in /usr/lib/apache/1.3/ to see if the modules you need are there. Knoppix includes quite a few modules, including support for CGI, server-side includes, PHP4, mod_rewrite , and SSL, and also comes with MySQL so you can run a database-driven site. If you need to use any Apache modules, check /etc/apache/modules.conf and make sure they are listed in there. Not all modules Knoppix includes are automatically listed in that file, so, for instance, to add server-side include support, add this statement to your copy of /etc/apache/modules.conf :

 LoadModule includes_module /usr/lib/apache/1.3/mod_include.so 

If Apache doesn't have the modules you need, you must remaster Knoppix with your custom Apache setup [Hack #94] . Otherwise, the next step is to actually copy over the pages you want to serve, and configure Apache to use them.

If you choose, you can use your Apache configuration for your current server. This may mean restoring the configuration from tape backup if you cannot directly access it from its current hard drive. Simply copy your complete Apache configuration to a suitable spot, like /home/knoppix/apache , and use it by creating a symlink to it:

 knoppix@ttyp0[knoppix]$  sudo mv /etc/apache /etc/apache.bak  knoppix@ttyp0[knoppix]$  sudo ln -s /home/knoppix/apache /etc/apache  

Otherwise, you must edit Knoppix's Apache configuration. All of the Apache configuration in Knoppix can be found in a series of symlinks in /etc/apache/ that point to files on the CD-ROM, which are, of course, read-only. To make changes to these configuration files, you must first make them writable. The following step seems a little odd, but it breaks the symlink with the CD-ROM and gives you a writable httpd.conf on the ramdisk . You can repeat the process with other configuration files you need to modify.

 knoppix@ttyp0[knoppix]$  sudo mv /etc/apache/httpd.conf /etc/apache/httpd.conf.bak  knoppix@ttyp0[knoppix]$  sudo cp /etc/apache/httpd.conf.bak /etc/apache/httpd.conf  

With the configuration files now writable, you are able to modify /etc/apache/httpd.conf and add any special changes you need to make for your site, such as adding multiple virtual hosts or changing the location of the DocumentRoot directory. Remember that when copying over the configuration and the accompanying web content, you must change any paths in httpd.conf to point to the new content directories that you have created. Also, if you are adding virtual hosts, remember to change the IP addresses to match this machine if necessary.

Once you have your files and configuration copied over, running Apache is as simple as:

 knoppix@ttyp0[knoppix]$  sudo /etc/init.d/apache start  

You shouldn't notice much of a performance hit for running off of the CD, because most of the site is running from ramdisk, and Apache itself runs completely from memory once it is loaded. However, there is less RAM to use overall because of the ramdisk Knoppix creates.

With this functionality, you can easily turn some desktop machines into mirrors of your web site or possibly even emergency replacements for the site while you change out hardware or perform software upgrades. The nice thing about using Knoppix for your emergency web server is that you can run it on top of any PC regardless of OS installation. When you are done, you can just log out and reboot the machine, and no one will know the difference.

 < Day Day Up > 


Knoppix Hacks. 100 Tips and Tricks
Knoppix Hacks. 100 Tips and Tricks
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net