wood burning stoves 2.0*
The moose likes Tomcat and the fly likes How to make a file executable as CGI process on Apache server ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "How to make a file executable as CGI process on Apache server ?" Watch "How to make a file executable as CGI process on Apache server ?" New topic
Author

How to make a file executable as CGI process on Apache server ?

nirjari patel
Ranch Hand

Joined: Apr 23, 2009
Posts: 368
How to configure a script to be made executable on apache server. This question is regarding cgi processes.
I saw following entries in an article.

Does it mean that any entry in config file mentioned as "cgi-anything" makes the script to be executed as cgi process ?

cgi script can be created in any language as perl, php, c, etc. If I want scripts in these lanaguages to be treated as cgi process, shall I modify httpd.conf file as follows
AddHandler cgi-script .cgi, .pl. .php, .c ?

So is this the only way a file can be executed on server before sending output to browser ? Is there other way , a script can be configured to be executed on apache ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15958
    
  19

I think you may be confusing the Apache httpd server (generally simply called "Apache") with the Apache Tomcat Server. They are 2 quite different programs, and Apache httpd can't execute Java code except as a cgi program.

CGI can be any command-line executable (non-GUI) application, providing it follows certain rules, such as outputting the results to stdout, including the appropriate HTTP header information.

Two things to be aware of:

1. It can be a real to debug CGI, since if the CGI app fails, the error messages you get from Apache are both sparse and fairly useless. Not the kind of thing to be undertaken lightly.

2. Java is not a good language for CGI. Since CGI's are, in fact, executable as stand-alone applications (even CGI scripts!), that means that you have to do all the usual things, including starting a JVM. Every Single Time a request is made to the CGI. This can result in some serious overhead and response-time issues. In fact, Perl and Python have resorted to cheating. There are special Apache modules that accelerate requests for scripts in these languages by eliminating a lot of the startup overhead.

Among the languages you can use to develop CGI's are the OS command shell itself - bash, csh, kch, or whatever. You can use the "shebang" convention to indicate which shell is to be used.

Normally, you'd simply add the ".cgi" extension to your CGI script/program, regardless of what language it was written in. Among other reasons, this makes it easier to secure the site, since it makes a positive indicator that the only valid CGI's are ones whose names end with ".cgi". People have been known to exploit servers that would serve up arbitrary executables.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make a file executable as CGI process on Apache server ?
 
Similar Threads
libphp5.so is garbled-apache server not able to start
Apache 2.2.4
Object not found, CGI problems again!
IHS/Apache with CGI - shell script
Tomcat + Apache mod_jk PUT gives 405