7

A script makes a GET request to my URL like so:

http://mydomain.com/cgi-bin/uu_ini_status_audios.pl?tmp_sid=b742be1d131c4d32237a9f1fcdca659e&rnd_id=0.2363453360320319

However, I get a 404 returned straight away:

The requested URL /cgi-bin/uu_ini_status_audios.pl was not found on this server.

But that script exists on my server, I can see the file! It has the correct permissions (I gave it a 777 to be sure). It is also owned by my apache user and its in the group apache.

What am I missing??

Thanks for any help on this!

Update

I thought it would have been a htaccess (rewrite) but I don't think it is anymore. I tried putting a index.php file in there and try to access it via my URL but I can't even do that! I tried this:

http://mydoamin.com/cgi-bin/index.php - same 404 error! I get this in myerror log:

[Tue Sep 14 14:42:49 2010] [error] [client xx.xxx.xx.xxx] script not found or unable to stat: /var/www/vhosts/mydomain.com/cgi-bin

Access_log file:

xx.xxx.xx.xxx - - [14/Sep/2010:14:48:25 +0200] "GET /cgi-bin/index.php HTTP/1.1" 404 475 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.9) Gecko/20100824 Firefox/3.6.9 (.NET CLR 3.5.30729)"

Update 2

My htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^blog/ - [L]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
RewriteRule ^search/(.*)/(.*)/(.*)/(.*) /search.php?searchfor=$1&sortby=$2&page=$3&searchterm=$4
RewriteRule ^confirmemail/(.*) /confirmemail.php?code=$1
RewriteRule ^resetpassword/(.*) /resetpassword.php?code=$1
RewriteRule ^resendconfirmation/(.*) /resendconfirmation.php?userid=$1
RewriteRule ^categories/ /categories.php
RewriteRule ^([-_~*a-zA-Z0-9]+)(\/)?$ /memberprofile.php?username=$1
RewriteRule ^browse/audios/(.*)/(.*)/(.*)/(.*) /audios.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^browse/categories/audios/(.*)/(.*)/(.*)/(.*) /categoryaudios.php?sortby=$1&filter=$2&page=$3&title=$4
RewriteRule ^audios/(.*)/(.*) /playaudio.php?audioid=$1&title=$2
RewriteRule ^download/audio/(.*)/(.*) /downloadaudio.php?AUDIOID=$1&title=$2
RewriteRule ^members/audios/(.*)/(.*) /memberaudios.php?pid=$1&username=$2
RewriteRule ^syndicate/audios/(.*)/(.*) /syndicateaudios.php?filter=$1&title=$2
</IfModule>

Update 3

[root@smydomain ~]# ls -la /var/www/vhosts/mydoamin.com/httpdocs/cgi-bin/
total 60
drwxr-xr-x  3 apache root     4096 Sep 14 14:37 .
drwxr-x--- 20 som    psaserv  4096 Sep 14 14:40 ..
drwxr-xr-x  2 apache root     4096 Sep  7 03:01 configs
-rwxrwxrwx  1 apache root        4 Sep 14 14:37 index.php
-rwxrwxrwx  1 apache apache   6520 Sep  7 03:01 uu_ini_status_audios.pl
-rwxr-xr-x  1 apache root     3215 Sep  7 03:01 uu_lib_audios.pl
-rwxr-xr-x  1 apache root    30249 Sep  7 03:01 uu_upload_audios.pl
Abs
  • 1,429
  • 4
  • 18
  • 32
  • You tagged this with mod-rewrite, is there a rewrite rule involved? Do any perl scripts work? Have you tried running it from the CLI? – Chris S Sep 14 '10 at 12:38
  • Also, append the appropriate logs from your `access_log` and `error_log`. – Andrew M. Sep 14 '10 at 12:39
  • It's a long shot because I'm unfamiliar with Apache but, have you defined the MIME type and handler for .pl extension ? Because on IIS, if no handler and no mime type is defined for a file, it will report it as 404. – Stephane Sep 14 '10 at 12:40
  • That would merely interpret how the browser handled the file; Apache is a bit more lenient than IIS. :) – Andrew M. Sep 14 '10 at 12:45

3 Answers3

4

SuExec was causing the problem for me.

Disabling this means my scripts in the cgi-bin can run. But you must make sure the directory and the scripts have the same permissions i.e. 0755. In addition, the directory and the scripts must be owned by the same person.

These were the requirements to get my scripts working! I hope this helps someone.

Abs
  • 1,429
  • 4
  • 18
  • 32
1

In your post, you said that it could not find /var/www/vhosts/mydomain.com/cgi-bin; what happens when you run ls -la /var/www/vhosts/mydomain.com/cgi-bin?

Also, I noticed that it said it couldn't stat the cgi-bin folder; is your mod_rewrite rule forwarding all requests from /var/www/vhosts/mydomain.com/cgi-bin/index.php to /var/www/vhosts/mydomain.com/cgi-bin erroneously?

Update your question if you find out more.

EDIT: Enable the mod_write log by setting the following:

RewriteLog /path/to/where/logs/live
RewriteLogLevel 5

This should give you sufficient data with which to see if mod_rewrite is affecting your request.

Brad Mace
  • 1,006
  • 3
  • 17
  • 31
Andrew M.
  • 10,982
  • 2
  • 34
  • 29
  • I added update 3 to show the result of the `ls -la` command. – Abs Sep 14 '10 at 12:58
  • Btw, when I tried to add the rewrite level - i got an error("Invalid command 'RewriteLevel', perhaps misspelled or defined by a module not included in the server configuration ") after restarting the apache server that it didn't recognise it. Also nothing is getting added to that log - suggests no errors? – Abs Sep 14 '10 at 13:00
  • Ah its, `RewriteLogLevel`. – Abs Sep 14 '10 at 13:04
  • I can not see any errors in the rewrites, they seem to go to the right place and the actual pl file I am trying to access is not mentioned in this log, so I guess its not a redirect issue?? – Abs Sep 14 '10 at 13:11
0

I've also seen errors where a URL was reported as 404 to Firefox. Passing the same url to wget returned a 500 Internal Server Error and showed errors in the log file. May be worth a try with wget for anyone else having this problem.

In my case it was the result of trying to include a file in a PHP script from a directory that didn't exist.

Brad Mace
  • 1,006
  • 3
  • 17
  • 31