.
Tips For Linux

>> Installing and Configuring Apache Web Server - Part 3

This part of the article deals with letting users on your machine host their own websites that would be served by the Apache Web Server. Initially I had mentioned that this article would be aimed at a single homeuser who is using Apache Web Server for development purposes on his home computer. But since you are not supposed to be working as the superuser for your general Linux work, you must have most probably created a user account which you use regularly. So if you want a proper website for development (when logged in as that user) you would have to set up Apache Web Server as follows


Creating
User Directories For User Homepages

If you want to create separate directories for all your users then you can define the name of the directory where the users must put their HTML pages.. Once the users put the pages in that particular directory, then that users
website can be accessed by typing the following in the browser.
http://127.0.0.1/~username

The directive necessary to enable this in the httpd.conf file is called
UserDir public_html

The above line would require all users who want to make their own websites to have a directory named 'public_html' within their home directory and they should put their html pages within that directory. Remember that the directory that you specified in the directive is not a common directory for all users to put their files. It basically is a name for a directory that the user must create within his home directory and put his webpages in. Apache would do all the internal mapping that is required when the website is asked for.

Also note that you may have to uncomment a few lines in the httpd.conf file (in case they are commented in the first place) The lines are generally just below the UserDir directive. They are enclosed with a <Directory> tag. There are a total of around 10-12 lines. I have just shown you the basic structure of those lines. Just uncomment these lines, don't change any of these lines.

<Directory /home/*/public_html>
.
.
<Limit>
..
</Limit>
<Limit>
.
.
</Limit>
</Directory>

Uncomment all of the above lines right from <Directory> upto </Directory>


Example

Suppose there is a user named david then his webpage could be accessed using the following address http://127.0.0.1/~david
This request would map into the following location /usr/home/david/public_html/
This would be the case if /usr/home/david is the home directory of the user named david.

Remember that in the above case since a particular filename was not specifically asked for, Apache would search for the filenames in the order set by the directive named DirectoryIndex as explained before (start by searching for a file named index.html.. and then proceed to search for other named files.)

Important : In case you are using this to create a webpage for a user, you have to give Enter/Execute permissions for your Home directory as well as your public_html directory and all other directories that exist within your website. Execute permissions must be set for user, group and others. The pages (.html and others) need to have only read access for user, group and others set. When you right click on a directory within KDE you get to see the permissions for that directory. Check the 3rd column. Only if you do this will you be able to view the pages within that directory else you would get a ' 403 forbidden error ' stating that you do not have the permissions to view this page.


Checking Log files to detect any problems

Apache logs all its actions in two files named ' access_log ' and ' error_log '. These files are found in the /var/log/httpd directory. These can be read by normal users, so you don't have to be the superuser to check what went wrong in case your webpage doesn't come up.

The access_log files maintains a note of the IP address from where a page was requested (makes more sense when you have Apache serve pages to strangers accessing yourwebpage from other machines), the exact time the request was made and also the exact resource that was requested.

The error_log also maintains a detailed list including a description of the errors that have occurred and the exact time they occurred.

There is a directive in the httpd.conf file that sets the amount of log that Apache should generate. It is as follows
LogLevel debug

LogLevel accepts various parameters such as debug, info, warn, crit etc. You can set it as per your choice. Whenever you are programming and trying out something for the first time its a good idea to set this as debug level, so that you get a detailed idea about what exactly is happening behind the scenes.

Goto Part 2 of this article

>
Tips For Linux © All Copyrights Reserved