0

I have got url like this:

http:// ipadress/project/cgi/sessionlogin.cgi?login=usernmae&password=somepass

but when I open this url I see download action of cgi file, not a results. I have .htaccess in folder with cgi scripts (/var/www/html/project/cgi) with this info:

AllowOverride None
Options +Indexes +ExecCGI +MultiViews +SymLinksIfOwnerMatch
#Order allow,deny
Require all granted
Allow from all

I also have this part in virtualhost config:

ScriptAlias /cgi-bin "/var/www/html/project/cgi/"

<Directory "/var/www/html/project/cgi">
        AllowOverride None
        Options +Indexes +ExecCGI +MultiViews +SymLinksIfOwnerMatch
        #Order allow,deny
        Require all granted
        Allow from all
</Directory>

But it all stiill is not working. cgi module is enabled. This is C++ binary cgi files. What I am doing wrong?

1

For starters, setting AllowOverride None means that any .htaccess file will be ignored (which is a good thing since you already have access to the main Apache VirtualHost config) so you might as well delete the .htaccess file.

Second the actual CGI file needs to have the correct permissions to be executable by Apache (chmod 755) and if you're running SELinux you might need to activate the httpd_enable_cgi SELinux boolean and ensure that the CGI file is labeled with httpd_sys_script_exec_t.

1

Although my system is Apache24 on windows 8.1, i think this problem is more general regardless of systems. I had a working configuration with Apache22 on windows 7 and i did not do any remarkable change when upgrade to apache24 on windows 8.1. When i googled for this problem , i realize there is no general solution. Obviously Apache24 did not see my_file_extension as executable.

Moreover,although i cleared the firefox cache from "c:\users\appdata\local\temp" directory, and remove the file from disc; firefox constantly gave the same file from my file system (namely file:\\c:\users\appdata\local\temp\the-file). And this situation existed for each of my servers (one server on my main machine and server on the other test machine).

So the solution i found (i think more general, at least works for me) is using the "Module mod_actions" directive ("Action" Directive).

To sum up : My old configuration is like this

#for alias_module
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"

# for cgi directory
# my_file_extension is ksp
<Directory   "c:/Apache24/cgi-bin">  
  AllowOverride None
  Options +ExecCGI 
  Require all granted       
  Addhandler cgi-script .ksp
</Directory>

and new configuration is like this

#for alias_module
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/"

# for cgi directory
# my_file_extension is ksp
<Directory   "c:/Apache24/cgi-bin">  
  AllowOverride None
  Options +ExecCGI 
  Require all granted           
</Directory>

# then the new directive i added;
# for any file in the server root directory that has an extension .ksp
<Location />     
  AddHandler ksp  .ksp
  Action ksp "/cgi-bin/CGI_KSP.exe"
</Location>

In the apache's documentation for Action directive, as an example

Example: File extension

# Files of a particular file extension
AddHandler my-file-type .xyz
Action my-file-type "/cgi-bin/program.cgi"

In this example, requests for files with a file extension of .xyz are handled by the specified cgi script /cgi-bin/program.cgi.

Hope this helps...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.