2

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?

3 Answers 3

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...

1

I do not know whether this would be something new in Apache2 on Ubuntu 20.04, but I had a problem where my executable would not start. Instead, Apache2 would offer me to download it.

It took me some time to find "a work around" (I think that's a huge bug in Apache2) which was to change the alias path.

This failed, no matter what:

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

I used a unique name for my website like so:

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

And it works like a charm!!!

I'm thinking that there is a conflict between different <VirtualHost ...> using the same ScriptAlias or something like that. I've not been able to find the exact cause of this issue. But now my site works as expected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .