|
|
Installing / Configuring the Apache Web Server (Release 2.0.43)
by Jeff Hunter, Sr. Database Administrator
Overview
The Apache Web Server source code can be downloaded from the Apache Web Site. The software is located at: http://httpd.apache.org/download.cgi.Simply download the file httpd-2.0.43.tar.gz (or equivalent version) and place it in a temporary directory.
This section of the document will make the following assumptions:
One decision you have to make is whether to use mod_jserv or mod_jk as the linking mechanism between Apache and Tomcat. Unless you can find a binary distribution of Apache with DSO support enabled (and I have searched long and hard), you will have to follow these instructions to build it yourself.
- The installation of the Apache Web Server will be performed as the "root" userid.
- The installation of the Apache Web Server will be performed from the /tmp directory. When downloading the Apache Web Server source code, download it to the /tmp directory.
- The Apache Web Server will be installed to /u02/app/apache.
- The Apache Web Server will be run on well-known port 80, and will therefore need to be started and stopped as the UNIX "root" userid.
- The Apache Web Server will run as any user. Since most of my installations will reference an Oracle database, I the "oracle" userid and group "dba".
Apache has added to the number of connection mechanisms to integrate the Apache HTTP server and the Tomcat Servlet container. The only choices with Apache 1.3 were to use mod_jserv or mod_jk. With Apache 2.0 you now have the following options:
- mod_jserv
- mod_webapp
- mod_jk
- mod_jk2
Installation Steps
# su - # mkdir /u02/app/apache # cd /tmp # gunzip httpd-2.0.43.tar.gz # tar xvf httpd-2.0.43.tar # cd httpd-2.0.43 # ./configure --prefix=/u02/app/apache --enable-module=most --enable-shared=max # make # make install # rm -rf /tmp/httpd-2.0.43
Configuring the Apache httpd.conf File
Configuring the Apache Web Server mainly includes making edits to the /u02/app/apache/conf/httpd.conf file.The following listing is an example httpd.conf file that details the changes you may want to make. The changes documented below configure the Apache Web Server to:
- Change the port number (now called Listen in Apache 2.0) from its default (8080) to run on port 80.
- I normally have the Apache Web Server run as the "oracle" userid and group "dba".
- Have the main DocumentRoot set to /u02/app/apache/WebDBA.
- Allow CGI programs to be run from any directory.
- Allow Server Side Includes.
- Allow the Apache Web Server to recognize index.html, index.htm, index.shtml, and index.cgi.
- CGI Scripts will be recognized by the filename extensions .cgi and .pl.
- Have the Apache Web Server parse filenames with extensions .shtml and .inc before returning the page to the browser.
The following listing is an example of setting up the httpd.conf file. All needed changes are provided in the table below.
Directive Value Listen 80 Make sure the "Listen" is set to "80". The old value for this in Apache 1.3 was named "Port". User oracle
Group dbaEnsures that the HTTP Server is running as the UNIX user: oracle:dba. ServerName www3.idevelopment.info Make note of this value, as it will also need to be set in the server.xml file for Tomcat. DocumentRoot "/u02/app/apache/WebDBA" By default, the entry point for the server is "htdocs". To ensure that it is pointing to the correct entry point to the web server, change the value of "DocumentRoot". <Directory "/u02/app/apache/WebDBA"> If you altered the value of "DocumentRoot" (above), you will need to change the very next <Directory> element attribute. Options Indexes FollowSymLinks ExecCGI Includes MultiViews Within the <Directory> element you defined above, set the "Options" value to ensure proper execution of CGI scripts. AllowOverride All Within the <Directory> element you defined above, set the "AllowOverride" value to ensure proper execution of CGI scripts. DirectoryIndex index.html index.htm index.shtml index.cgi Make sure that the DirectoryIndex directive allows for all required file extensions. AddHandler cgi-script .cgi .pl Ensures that the HTTP Server will execute CGI scripts. This option is commented out by default. AddType text/html .shtml
AddOutputFilter INCLUDES .shtmlEnsures that the HTTP Server will parse all required files with the given extension. NOTE: Keep in mind that in Apache 1.3, in order to process Server Side Includes, you would need to include the following:AddHandler server-parsed .shtml .html .htm .inc
DO NOT include this line when using Apache 2.x and you are using .html files under the Tomcat servlet container. Having this line included will cause all requests for HTML/SHTML files within the Tomcat container directories for fail with a URL not found error. The error is visible in the error log file for the Apache webserver.
NameVirtualHost You can (optionally) setup one or more Virtual Hosts. NameVirtualHost 192.168.1.110 <VirtualHost 192.168.1.110> ServerAdmin dba@idevelopment.info DocumentRoot /var/www/WebDBA ServerName dbaprod.idevelopment.info ErrorLog logs/WebDBA-error_log TransferLog logs/WebDBA-access_log </VirtualHost> <VirtualHost 192.168.1.110> ServerAdmin dba@idevelopment.info DocumentRoot /var/www/OracleDocs817 ServerName oracledocs817.idevelopment.info ErrorLog logs/OracleDocs817-error_log TransferLog logs/OracleDocs817-access_log </VirtualHost> <VirtualHost 192.168.1.110> ServerAdmin dba@idevelopment.info DocumentRoot /var/www/OracleDocs901 ServerName oracledocs901.idevelopment.info ErrorLog logs/OracleDocs901-error_log TransferLog logs/OracleDocs901-access_log </VirtualHost>
Starting / Stopping Apache Web Server
Starting ApacheTo start the Web Server, log in as the root account and run the following: (provided your PREFIX is /u02/app/apache).
# su - # /u02/app/apache/bin/apachectl startStopping ApacheTo shut down the Web Server, log in as the root account and run the following: (provided your PREFIX is /u02/app/apache).
# su - # /u02/app/apache/bin/apachectl stop