Linux Know-How provides a collection of introductory texts on often needed Linux skills.

Simple web server (running Apache)

To set up a simple apache web server was extremely easy under RedHat 6.0. First of all, I made sure to install the apache web server rpm package during my RedHat installation. If you didn't do it, you can put the RH CD in your CDROM now, mount it, and install the package apache-*.rpm (instead of the "*" the name also contains the version number and the platform). If I know what I want to install, it is simple do it (as root):

cd /mnt/cdrom/RedHat/RPMS

rpm -ivh apache*.rpm

Then, I run "setup" (as root) and make sure that the httpd daemon (under "system services") is enabled. [A daemon is a program that sits in the background and wakes up when it is needed. In the case of httpd, it gets awakened when somebody calls on your http server.]

Now, the httpd will start automatically every time I boot the computer. I can also start it manually using (as root):

/etc/rc.d/init.d/httpd start

and shut it down using:

/etc/rc.d/init.d/httpd stop

I should already have the directory: /home/httpd (check if it exists), and under it, the subdirectory html--this is the "root directory" for people accessing my computer from the web ( "their root directory" means that they will not be able to access any directories above the directory /home/httpd/html/ on your system). On default, this directory contains some html files and manual that the apache installation program put there. So I should now be able to connect to my web server from another machine on my home network. For example I would type on the Netscape "Location" line:


and be able to browse the "apache" manual.

To put my own content on my web server, I move the "apache" sample files somewhere else, and copy or link my html files (the ones which I want to display to the public) to the directory /home/httpd/html/ (don't forget to include the the file index.html , this is the one that appears first when somebody connects to your server).

The apache configuration files and log files are in the directory /etc/html/ if you wanted to view/customize them. The log file can be viewed in "real time" using this simple command (as root):

tail -f /etc/httpd/logs/access_log

[The tail command normally displays the end ("tail") of a text file. With the option "-f", "tail" keeps displaying the end of the log file as it grows--really handy to monitor the log file and see who logs onto your server.]

For graphical setup of the Apache server, try this (in an X-window, as root, if you installed "Comanche" from your RedHat CD):


Last Update: 2010-12-16