Apache Web Server
The apache web server is called "httpd". The configuration files for it for many systems are in "/etc/httpd/conf". Their names are httpd.conf, srm.conf, access.conf, mime.types, and magic. The file srm.conf specifies the directory location of the root document with the "DocumentRoot" statement. The "DirectoryIndex" statement gives the name of the starting file. The file access.conf, is used to control user access to various html files. On my system, the initial startup file is "/home/httpd/html/index.html". Documentation is in /home/httpd/html/manual.
There are many options that can be selected when installing Apache. Among them are selection of the modules to be compiled with the apache web server. This will be commented on at the appropriate installation step. In my installation, I installed Apache with PHP and mysql support. To get the Apache compile to work with mysql support, it was necessary for mysql to be installed from the source. When mysql was installed from binary, the apache compile failed. Here's the installation steps for installing Apache from a tarred and zipped source file:
- Copy the source file to "/usr/src" or "/usr/local/src". The source file is called something like apache_1_3_19_tar.gz.
- Type "cd /usr/src" or "cd /usr/local/src" depending on where you copied your file.
- Type "tar xvzf apache_1_3_19_tar.gz" to decompress the source file. The directory, "apache_1.3.19" is created.
- Type "ln -s apache_1.3.9 apache" to create a software link to the apache directory.
- If installing PHP support with apache, copy the PHP source file "php-4_0_4pl1.tar.gz" from php.org to "/usr/src" or "/usr/local/src".
- Type "tar xvzf php-4_0_4pl1.tar.gz" to decompress the source file.
- Type "cd apache".
- Documentation at the apache.org web site indicates to enter the "src" directory to perform the configuration and compile. However by reading the "INSTALL" files in the apache and apache/src directories, it can be done from inside the src directory or from the main apache directory. Either approach will work. There are various advantages and disadvantages to each approach. Compiling from inside the "src" directory allows easier module control by allowing the changing of the "Configuration" file. If done from the main directory, modules to be included or excluded from the default setting must be included on the command line. I have chosen to do the install using the "configure" file in the main directory since documentation indicates that some parameters may be overridden here and I am making no changes to the default included modules. If you want to install PHP support, there is a way to do it as documented in PHP INSTALL file, but I have not outlined that procedure here and have assumed you will be performing the install from the main directory if installing PHP. If you want to change the default modules by compiling in the "src" directory, follow the subset of instructions below.
- Type "cd src".
- Edit the file "Configuration" file.
- Type "./Configure". I do not believe you can use the options "--sysconfdir" and "--logfiledir" to specify configuration and loglile locations as I have done below.
- Skip the next step (Step 7).
- Type "./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/conf --logfiledir=/var/log/httpd". I have added the "--sysconfdir" option to set the location where the apache configuration files will be, and the "--logfiledir" option to set the location of where logging information is written for apache. If you are making changes to the default modules use the additional command line parameters "--enable-module=NAME" and "--disable-module="NAME" where "NAME" is the name of the module to be enabled or disabled. Read the "INSTALL" file in the main directory for more information here and read the "src/Configuration" file to see what the module names are. If installing PHP support follow the subset of instructions below.
- Type "cd .."
- Type "cd php-4.0.4pl1"
- Type "./configure --with-mysql=/usr/local/mysql --with-apache=../apache --enable-track-vars". This assumes you've already installed mysql in the "/usr/local/mysql" directory.
- Type "make".
- Type "make install".
- Type "cd ../apache".
- Type "./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd/conf --logfiledir=/var/log/httpd --activate-module=src/modules/php4/libphp4.a"
- Type "make". Note: When I did my install, I got a compile error related to the mysql installation. If you installed the binary version of mysql, you may need to install it from the source version.
- Type "make install". If installing PHP support follow the subset of instructions below.
- Type "cd ../php-4.0.4pl1".
- Type "cp php.ini-dist /usr/local/lib/php.ini".
- Edit "/etc/httpd/conf/httpd.conf" or "/etc/httpd/conf/srm.conf" and add the following line:
AddType application/x-httpd-php .php
At this point it is time to set up the apache configuration by modifying the apache configuration files and setting apache to start automatically. The apache configuration files are:
- httpd.conf - This is the main configuration file. It is used to specify where the document root for the web server is found, various server parameters, directory permissions, where mime types for files are found, and addition of application type definitions and the associated handler for each application.
- srm.conf - This file is used to configure apache server directives. These directives are now recommended to be put in the httpd.conf file.
- access.conf - This file is used to control directory access and who can access the directories. The directory access control is now recommended to be put in the httpd.conf file.
Specific configuration parameters:
- Specification of the document root where the HTML main web page, "index.html" should be found. This line should look like:
- Additional parameters including:
- ServerRoot - Specifies where the servers main directory is.
- ErrorLog amd Loglevel- Specifies where the web server will keep its error log file and the level at which errors are kept. Loglevel options are debug, info, notice, warn, error, crit, alert, and emerg.
- Keep alive - Specifies whether persistant connections are to be supported.
- KeepAlive Requests 100 - The maximum keep alive requests to be supported.
- KeepAliveTimeout 15 - The number of seconds the connection is kept alive if no additional requests are received from the client.
- The maximum and mininum number of servers that may be created to wait for client requests and the number of servers to start when the web server starts.
- MaxClients 150 - The maximum number of clients that may connect at one time to the web server.
- Port 80
- The user and group the web server is run as.
- Directory permission entries are used to define various directory options and permissions. These entries appear similar to the following which defines the permissions for the document root directory:
Allow Override None
- ExecCGI - Allows CGI programs in the directory to be executed.
- None - No options
- All - All options except MultiViews
- Permissions - Are set with statements such as:
Order deny, allow
Deny from all
Order allow, deny
Allow from all
<Limit> and </Limit> tag pairs along with <LimitExcept> and </LimitExcept> tags are set with options such as:
- <Files> and </Files> tag pairs can be set to limit access to specific file types the same as is done with directory entries above.
- CGI Driectory definition which defined what directory CGI application files are kept in and can be used to run these files. Other directories can be specified to allow the execution of CGI files if the ExecCGI option is specified in these directory entries.
Allow Override None
Order allow, deny
Allow from all
- AddType and Add handler statements. These statements allow file types and associated programs to handle these file types. You will linely need this set of entries to run PHP.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
To run server parsed SHTML files you will need:
AddType text/html .shtml
AddHandler server-parsed .shtml
This is just a partial list of common apache web server options. For a more complete guide, including setting up virtual hosts, refer to the Apache web server documentation.
Getting user filled out form data from the web
There are many types of programs that can be written to do this:
- Perl CGI scripts
- Shell CGI scripts
- PHP scripts that are scripts run on the server side when the page is requested. PHP code is embedded in the HTML page, but files are labeled with the .php extension.
- Java Servlets
- Compiled programs based on any language.
The CGI Environment:
The Web server fills in a standard list of environment variables when it runs. It writes to other environment variables when it is requested to. Since the Apache server always runs, anything it puts in the environment is readable by other programs, such as a Perl script program. This is possible as long as the other program knows the names of the variables to be read.
- CGI - Common Gateway Interface. A set of rules (interface) for scripting and exchanging data over the web.
- SGML - Standard Generalized Markup Language. HTML is an application of this.
- URL - Universal Resource Locator. Includes protocol (HTTP, FTP, FILE, GOPHER), module name, path name of object.
- IIS - Microsoft's Internet Information Server (A web server for NT)
- IDC - Internet Database Connector
- ISAPI - Microsoft web programming (Internet Server Application Programming Interface)