Thursday, August 7, 2008

Adding Perl CGI support into Apache server

Download ActivePerl from the internet

Modify the conf/httpd.con file in Apache


Add to the options in tag +ExecCGI, as follows


AcceptPathInfo On
Options FollowSymLinks +ExecCGI


Check that the file has

AddHandler cgi-script .cgi .pl


At the beginning of your program point where is your Perl executable are:

#!c:/program files/perl/bin/perl.exe

Just write your program and save it in .pl extension and access the file using

http://localhost/perlTest/hello.pl

Sunday, August 3, 2008

Connecting Tomcat & Apache

Go the Tomcat Connectors (mod_jk) Downloads

mod_jk is a module that passes specific requests from Apache to Tomcat. Tomcat processes a request, and sends the response back through Apache.

Apache Tomcat JK 1.2.26 for WIN32

  • mod_jk-1.2.26-apache-2.2.4.so is for Apache 2.2, and works with Apache 2.2.4 and later. Rename to mod_jk.so before putting it in your Apache2.2/modules directory.
  • tells Apache that the module exists and where to find it using a LoadModule directive, in conf/httpd.conf file.
  • The JkWorkersFile should point to the location of the file that specifies how mod_jk should connect to the Tomcat service and interact with the various worker processes created by Tomcat. tell Apache how to identify which Tomcat process to communicate and forward the request.
  • JkWorkersFile /usr/local/apps/jakarta-tomcat-4/conf/workers.properties
  • JkLogFile /usr/local/apache/logs/mod_jk.log

    JkLogLevel info

    JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

  • The file contains
  • workers.tomcat_home=/usr/local/apps/jakarta-tomcat-4

    workers.java_home=/usr/java1.4.1
    ps=/
    worker.list=ajp13
    worker.ajp13.port=8009
    worker.ajp13.host=localhost
    worker.ajp13.type=ajp13
That creates a connector called ajp13 (we'll need that in a minute), which is located on the local machine on port 8009. This is one of the standard ports listened to by Tomcat.

Forwarding Requests
The final step is to tell Apache which files should be assigned to Tomcat for processing and which of the workers to direct the request to. You do this using the JkMount directive, which effectively mounts a Tomcat worker process to a given file specification. For example, to redirect all requests for files ending in .jsp on this server to the worker identified as ajp13, you would use:

JkMount /*.jsp ajp13
The file specification uses Unix-like wildcard specifications, so we could have specified that all files be forwarded to Tomcat using:

JkMount /* ajp13

Testing it Out
To test out your installation, copy a suitable JSP or servlet into
your Web server directory and then try accessing it from a browser.
Remember that you must have both Tomcat and Apache running. Assuming
everything is working OK then you should get the desired result. If
there's an error, you'll need to check one of the various log files for
more information. To help you determine which one, look at the error
message reported in the browser.
If the error was generated by Tomcat, then you need to check the Tomcat logs in the main Tomcat installation directory. It probably means either there is an error in your JSP or a class on which it relies or there is a problem with accessing the file in question. Because requests are forwarded to Tomcat immediately, a missing file will be reported by Tomcat, not Apache.

If it's an error generated by Apache, check the Apache logs and the mod_jk logs. If the error is reported in the mod_jk log, then it probably points to a problem with the configuration somewhere.

If you get an Internal Server Error from Apache, then check whether Tomcat is running before digging any deeper.