Administrating the Server Here is a reference to setting up, maintaining and utilizing the information and resources provided by your server. How to: Constructing URLs to your server Now that you have an http server, you'll want to reference it in your HTML documents and with your favorite Web browser. Before you do anything, you should read the Beginners guide to URLs to familiarize yourself with URLs. You will want to pay attention to the section referring to HTTP URLs. Definition HTTP URLs have the basic form: http://servername:port/path servername Your server's full hostname. It can be the server's real name or a DNS alias. port This is the port which your server is listening on. Specifying it in the URL is optional. If omitted, it is assumed to be 80. If your ServerType is inetd, your port number was set in /etc/services. If your ServerType is standalone, the Port directive set your port number. path This is the path to the document. This is not the absolute pathname of the document on your machine. The server translates path as follows: 1. It looks for any defined Alias or ScriptAlias virtual names at the beginning of path. If it finds one, it replaces the virtual name with the real name and processes the request. 2. It looks for a prefix of /~, and if UserDir is not DISABLED, it will look in the user's public html subdirectory for the file. 3. It inserts DocumentRoot at the beginning of path and processes the request. Setting up your Home Page Some HTTP servers let you explicitly set up your home page (i.e. the page returned by the URL http://yourserver/ ). To do this using NCSA httpd, create a DirectoryIndex file in the DocumentRoot directory. Note that this index can be a symbolic link to another file. Examples My Resource Configuration file contains the following directives (among others): DocumentRoot /u/Web DirectoryIndex index.html ScriptAlias /htbin /usr/local/etc/httpd/htbin Alias /zftp /archive/ftp An HTML document references http://hoohoo.ncsa.uiuc.edu/docs/Overview.html. The server finds no Alias or ScriptAlias virtual names in path, so it returns the file /u/Web/docs/Overview.html. Someone references my home page as http://hoohoo.ncsa.uiuc.edu/. The server finds no virtual names, so it returns /u/Web/index.html. Another HTML document references http://hoohoo.ncsa.uiuc.edu/htbin/uptime. The server finds the ScriptAlias /htbin at the beginning of path, and so executes the script /usr/local/etc/httpd/htbin/uptime. Another HTML document references http://hoohoo.ncsa.uiuc.edu/zftp/README.txt. The server finds the Alias /zftp at the beginning of path, and returns the file /archive/ftp/README.txt. Managing the standalone daemon Info on Restarting or Terminating the standalone daemon If you are using a ServerType of inetd, you do not need to read these instructions. If you make any changes to httpd's configuration files, you must restart the server. To do so, you will need to know where the server has logged its process id, given by the server configuration directive PidFile. If pidfile is the setting of PidFile for your server, to restart the daemon execute the following on the command line: kill -1 `cat pidfile` This will restart the daemon. You should now check to see if the daemon restarted successfully. Check the last line of the server's error log, given by the server configuration directive ErrorLogFile, and make sure it says httpd: successful restart. Alternatively, you may use the ps command to grep for the process id of the daemon. If you ever need to terminate the server, use the following command: kill `cat pidfile` Managing the Log Files If you are using a ServerType of inetd, you may remove or move the log files periodically using mv or rm with no effect on the server. The standalone daemon opens the log files once when it starts up, and does not close them until killed. This is because the fopen() system call has a lot of overhead. To rotate one of the log files, do the following: 1. Move the log file to a new name with the mv command 2. Restart the standalone daemon This will cause all new server processes to log to the new log file. You may then do what you wish with the old log file. The Improved imagemap Script Eternal gratitude to Kevin Hughes, kevinh@pulua.hcc.hawaii.edu, for his code to find intersections of points with circles and polygons. Compile the imagemap script If you downloaded the source, you need to compile the imagemap script. Do this by first cd'ing into your ServerRoot, and then cd into the cgi-src subdirectory. Then, type make imagemap and you should be all set. The Central Configuration File The imagemap script expects to find its configuration file as: /usr/local/etc/httpd/conf/imagemap.conf. If you would like to change the location of this file, edit cgi-src/imagemap.c, change the setting of CONF_FILE, and recompile with make imagemap. In this file, lines beginning with a # are comments. Every other non-blank line consists of: name : path name is the name of the particular mapping. You use it when you reference the image. path is the full path to the map configuration file for this mapping. Notice: It is important to leave a space before and after ":". It is also important to finish your lines with . The Map Configuration File This file maps regions to URLs for the given image. Lines beginning with # are comments. Every other non-blank line consists of the following: method url coord1 coord2 ... coordn coord are each coordinates, format x,y. The number depends on method. method is one of the following: circle For a circle. Coordinates: center edgepoint poly For a polygon of at most 100 vertices. Each coordinate is a vertex. rect For a rectangle. Coordinates: upper-left lower-right url is one of the following: a virtual pathname to a file on your server (i.e. a URL to your server without the http://hostname part) a URL Note: each method is evaluated in the order it is placed in the configuration file. If you have overlapping areas, such as a circle inside of a rectangle, you should place whichever one you want evaluated first before the other in the map file. In this case, we would put the circle before the rectangle. Referencing Your New Map To reference your new map, you construct URLs pointing to it. For example, if you have a ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/, named your map fish, and used the image fish33.gif for the map, the following line of HTML will reference it: A Complete Example The fish demo in another section of this manual used the following configuration files: Central Configuration File fish : /usr/local/etc/httpd/conf/fish.map Map Configuration File The map configuration file used for this picture was rather lengthy. I used xv to get the coordinates. Write CGI scripts to handle forms Get the documents on CGI scripts and read those. Use server side includes in your HTML documents Get the tutorial documents and read section on server side includes. Managing Users To use user authentication, you'll need to edit and manage user files and group files. Using htpasswd to manage user files To deal with user files, we provide a program in the support directory of the distribution called htpasswd. Usage: htpasswd [-c] file user The -c, if present, tells htpasswd to create a new passwd file of the specified name instead of editing an old one. file is the pathname of the user file you wish to edit. The user parameter is the name of the user you wish to add or edit. If htpasswd finds the user you specified, it will ask you to change the user's password. Type the new password (it will ask twice). httpd will then update the file. If htpasswd doesn't find the specified user, it will ask you to give the user an initial password. Group files The format of the group file is as follows: groupname: member1 member2 ... Or, each line contains the name of a group, and a list of members separated by spaces. Edit the configuration files Get the documents on Installation and read the sections on Configuration.