Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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

Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
Saloon Keeper
Posts: 23449
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
look! it's a bird! it's a plane! It's .... a teeny tiny ad
SKIP - a book about connecting industrious people with elderly land owners
    Bookmark Topic Watch Topic
  • New Topic