Serving Up Web Pages with Apache


Apache is the world's most popular Web server, and with good reason — it's super powerful, stable, and secure. Basically, if you want to serve Web pages and related resources to folks, use Apache. End of story. Recognizing this, Knoppix includes Apache, and it's quite easy to get it going: As root, simply type apache on the command line and press Enter.

Apache is now running, and if you want to verify that, open your Web browser and go to http://127.0.0.1. You should see something like the page shown in Figure 3-14.

image from book
Figure 3-14: The default Apache page on your computer

By default, Apache loads files from /var/www, which means that you need to replace the files in that directory with those that you want to serve, or point Apache to a different directory. If you decide on the former, keep in mind that index.html is the default file, although index. htm, index.shtml and index.cgi will also work.

If you want to go with the latter, open /etc/apache/httpd.conf as root with your favorite text editor, find the line that currently says DocumentRoot /var/www and change /var/www to the directory of your choice. Look down about 25 lines or so and find the line that says <Directory /var/www> and change that one to <Directory new-directory> as well. Save your work and close httpd.conf.

You're not finished yet. You need to make sure that the directory you entered has world-readable and executable permissions, like this: chmod o+rx directory. Any directories containing the one you're trying to serve using Apache must also be world readable and executable as well. Once you're sure that your permissions are correct, enter apachectl restart on the command line as root. Reload http://127.0.0.1 in Mozilla, and you should see the contents of your new directory. Even if you don't have index.html or the equivalent set up, you should see a list of folders and files that you — or anyone else able to connect to your box — can view and download.

Tip 

If there's a problem and your content doesn't appear, make sure your path is correct next to DocumentRoot in httpd.conf, save it, and restart Apache (make sure you've got content in that directory!).

You'll never use Apache running on Knoppix to power your business or to serve up pages to thousands of users around the world, but in a pinch, it can be perfect to provide Web pages or any other content via the Web.



Hacking Knoppix
Hacking Knoppix (ExtremeTech)
ISBN: 0764597841
EAN: 2147483647
Year: 2007
Pages: 118

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