How to install Apache

Check to see that the Apache web server is loaded by typing the following: rpm -qa | grep httpd You should see the following:

httpd-manual-2.0.40-8
redhat-config-httpd-1.0.1-13
httpd-2.0.40-8

If you don't see this, then you will have to get it off the CD, or download Apache for your package. I am on FC3 so I went to the following:

http://mirrors.kernel.org/fedora/core/3/i386/os/Fedora/RPMS/
Next you need to edit the /etc/httpd/conf/httpd.conf file. Some significant variables are as follows:

ServerName 10.146.160.66:80

# This is the IP address of the computer. the :80 is the port that apache listens on - http
# Log files are kept in /var/log/httpd directory.

ServerRoot = "/etc/httpd"

# This is where the configuration files are kept. NOT to be confused with where the html files are

DocumentRoot = "var/www/html"

# This is where the html files for your web page are located. NOTE: don't put a trailing / in the string.

 

To start Apache, type the following: /etc/init.d/httpd start If all goes well, you should see the following message:

Starting httpd: [ok]

To have httpd start every time the server starts, type the following: chkconfig httpd on.

To test your web server, go to another computer that is connected to your network, and type in either the name of the server (sythompsom1) or the IP address you assigned to it. If all is well, you should get the test page.

If you are interested in setting up accounts for other people, in addition to setting up a regular user account on the server, you will need to comment out the variable UserDir Disable. You will also need to define each users' html folder. Then set the UserDir public_html directive in the httpd.conf file. Also add the following: UserDir disable root also add users into the UserDir directive. For example for user XYZ: UserDir enable XYZ.

The UserDir variable defines the folder that the user places their html files for their web pages. It needs to be in the user's home directory. In the example of user XYZ the directory structure would look like this: /home/XYZ/public_html. You will also have to set the permissions to their home directory set to 711. The public_html file must have permissions set to 755. Also all files in this folder must have their permissions set to 755.

If you try Accessing the index.html file via a Web browser, and get a "Forbidden 403" error on your screen, even though the permissions are correct, here is what you need to do:

chcon -R -h -t httpd_sys_content_t User_Folder_As_Defined_In_httpd.conf

This is because Fedora Core 3 introduced the concept of security contexts as part of the Security Enhanced Linux (SELinux) definition. A Web page may have the right permissions, but the Apache httpd daemon won't be able to read it unless you assign it the correct security context or daemon access permissions. Context-related configuration errors will give "403 Forbidden" browser messages, and in some cases, you will get the default Fedora Apache page where your expected Web page should be.

When a file is created, it inherits the security context of its parent directory. If you decide to place your Web pages in the default /var/www/ directory, then they will inherit the context of that directory and you should have very few problems.

For more on this, go to this web page.