Can't access cgi-bin folder

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Can't access cgi-bin folder

Postby PStechPaul » 22. January 2011 03:06

I just installed and configures XAMPP on my Win7 Home Premium 64 bit machine, and I copied my website folders SCGBG and cgi-bin to the htdocs folder, but when my HTML form tries to access a perl script in the cgi-bin folder I get an Object Not Found error. And if I type in the url in IE8 it gives a "Forbidden" or "Access Denied" error. I can use FileZilla to read the folder and files with no problem, but I can't set file permissions. The Windows folder properties seem to be the same as the SCGBG folder. And even if I rename the folder to something totally different I still can't access the files with the browser. I could not find anything about cgi-bin problems.

Thanks,

Paul
http://www.pstech-inc.com
PStechPaul
 
Posts: 7
Joined: 22. January 2011 02:38

Re: Can't access cgi-bin folder

Postby Sharley » 22. January 2011 03:25

The cgi-bin for the htdocs folder is \xampp\cgi-bin so you could move your scripts to that folder (or see the next paragraph) but change the shebang (first line of each script) to
Code: Select all
#!"\xampp\perl\bin\perl.exe"
so the scripts know where to find the perl interpreter and they should work by default - there is already a printenv.pl file in there to use as a test file which will have the correct shebang to use in your scripts.
Test:
http://localhost/cgi-bin/printenv.pl

You could try first leaving the cgi-bin where you have it at present but the shebang needs to be changed in each script so they know where to find the perl.exe file.
They may have at present the Linux default shebang if you downloaded your site from a hosting service
Code: Select all
#!/user/bin/perl
or similar which need to be edited to the location of perl.exe in XAMPP.

For example you would use the URI like so for your currently located cgi bin folder:
http://localhost/SCGBG/cgi-bin/myperlscript.cgi
Remember that Apache paths are case sensitive.


There is a workaround if you want to leave the shebang the same as that on your hosting service so it would be less hassle to keep changing that line all the time, but I have not tested it:
http://stackoverflow.com/questions/2036 ... h-apache-2
XAMPP's perl does not update the registry automagically on installation so you would have to follow the instructions in the above link to do it manually.

Good luck and best wishes,
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Can't access cgi-bin folder

Postby PStechPaul » 22. January 2011 05:38

OK, it's going a little further now, but I'm getting errors related to the DateTime module. I tried to install it twice, but I think it did so on my ActiveState Perl installation. I navigated to the xampp\perl\bin folder and used the command line:

Code: Select all
perl -MCPAN -e shell

and then:
Code: Select all
cpan> install DateTime


I'm getting the following errors in the error.log:
Code: Select all
[Fri Jan 21 23:07:56 2011] [error] [client ::1] Premature end of script headers: EventProcessor.pl
[Fri Jan 21 23:07:56 2011] [error] [client ::1] Can't locate Params/Validate.pm in @INC (@INC contains: C:/xampp/perl/lib C:/xampp/perl/site/lib .) at C:/xampp/perl/site/lib/DateTime/Duration.pm line 12.
[Fri Jan 21 23:07:56 2011] [error] [client ::1] BEGIN failed--compilation aborted at C:/xampp/perl/site/lib/DateTime/Duration.pm line 12.
[Fri Jan 21 23:07:56 2011] [error] [client ::1] Compilation failed in require at C:/xampp/perl/site/lib/DateTime.pm line 44.
[Fri Jan 21 23:07:56 2011] [error] [client ::1] BEGIN failed--compilation aborted at C:/xampp/perl/site/lib/DateTime.pm line 44.
[Fri Jan 21 23:07:56 2011] [error] [client ::1] Compilation failed in require at C:/xampp/cgi-bin/EventProcessor.pl line 57.
[Fri Jan 21 23:07:56 2011] [error] [client ::1] BEGIN failed--compilation aborted at C:/xampp/cgi-bin/EventProcessor.pl line 57.


But this is a script that works fine on the server and also locally using ActiveState Perl from the command line (except for the PHP). I did not need to change the shebang or any other paths for ActiveState on the local machine. I also have a simple script that works better:

Code: Select all
#!"C:\xampp\perl\bin\perl.exe"
# ! /usr/bin/perl -T
#
#   PurifierTest.pl-- A program to:
#   (1) Open and run the Basic.php script
#   (2) Send a notice back to sender
#
#   Modified in January 2011 by Paul E. Schoen
#
#   01/20/11 - Created from EventProcessor.pl

use warnings;
use strict;

#   Note: Content-type required only once for header
print <<EOF;
Content-type: text/html

<html>
<body>
<h3>Purifier Test Opening basic.php</h3>
<iframe src="basic.php"> </iframe>
</body>
</html>
EOF

print <<EOF;
<html>
<body>
<h3>Purifier Test Complete</h3>
</body>
</html>
EOF

exit ;


and the PHP script is:

Code: Select all
<?php

// This file demonstrates basic usage of HTMLPurifier.

// replace this with the path to the HTML Purifier library
require_once 'library/HTMLPurifier.auto.php';

$config = HTMLPurifier_Config::createDefault();

// configuration goes here:
$config->set('Core.Encoding', 'UTF-8'); // replace with your encoding
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional'); // replace with your doctype

$purifier = new HTMLPurifier($config);

// untrusted input HTML
$html = '<b>Simple and short';

$pure_html = $purifier->purify($html);

echo '<pre>' . htmlspecialchars($pure_html) . '</pre>';

// vim: et sw=4 sts=4


I'd like to be able to use the Apache server on this machine for testing, but this is getting frustrating. And now apparently I messed up by adding a password for the xampp phpadmin and I get this:

Code: Select all
Welcome to phpMyAdmin

Error
MySQL said: 

#1045 - Access denied for user 'root'@'localhost' (using password: NO)

phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.


I can't figure out how to fix this.

Thanks,

Paul
PStechPaul
 
Posts: 7
Joined: 22. January 2011 02:38

Re: Can't access cgi-bin folder

Postby Sharley » 22. January 2011 06:42

First lets get phpMyAdmin working as it is also related to getting MySQL working, they use the same root user/password.
I messed up by adding a password for the xampp phpadmin and I get this:
How did you set this password for phpMyAdmin?

The correct way is to use http://localhost/ and select the Security menu item then click on the link:
http://localhost/security/xamppsecurity.php
Then add your root user password in the MySQL section, leave the defaults as they are and click on the Password changing button - try again to access http://localhost/phpmyadmin


It may be quicker for your perl solutions by posting in our dedicated Perl forum, English is acceptable in those forums under Grundlagen und Wissenswertes.
Hopefully there you will find a more competent perl/php coder than I who may be able help by spotting straight away your problem.

Good luck and best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Can't access cgi-bin folder

Postby PStechPaul » 22. January 2011 07:52

Sharley wrote:First lets get phpMyAdmin working as it is also related to getting MySQL working, they use the same root user/password.
I messed up by adding a password for the xampp phpadmin and I get this:
How did you set this password for phpMyAdmin?

The correct way is to use http://localhost/ and select the Security menu item then click on the link:
http://localhost/security/xamppsecurity.php
Then add your root user password in the MySQL section, leave the defaults as they are and click on the Password changing button - try again to access http://localhost/phpmyadmin

Maybe for quicker perl answers try posting in our Perl forum, English is acceptable in those forums under Grundlagen und Wissenswertes.
Hopefully there you will find a more competent perl/php coder than I who may be able help by spotting straight away your problem.

Good luck and best wishes.


This is what I got:

Code: Select all
Security console MySQL & XAMPP directory protection
--------------------------------------------------------------------------------
MYSQL SECTION: "ROOT" PASSWORD
MySQL SuperUser: root
Current password: 
New password: 
Repeat the new password:   
phpMyAdmin authentication: http   cookie 
Set a random password for the phpMyAdmin user 'pma': Yes   No 
---- ----
(File: C:\xampp\security\mysqlrootpasswd.txt)
--------------------------------------------------------------------------------
XAMPP DIRECTORY PROTECTION (.htaccess)
User: 
Password: 
---- ----
(File: C:\xampp\security\xamppdirpasswd.txt)


I had tried to use a blank password, and it was not allowed. I had set the password because the security page
Code: Select all
http://localhost/security/

flagged this as a security risk.

OK, I got it to work by stopping and restarting the MySQL service. I still have problems with my Perl script. But I also tried running my "basic.php" script, and it complained that it must start with "#!". I did so, and I got a differfent error:

Code: Select all
(OS 193)%1 is not a valid Win32 application.  : couldn't create child process: 720193: basic.php


Update: I was able to move the scripts out of the cgi-bin and into the SCGBG folder. I added the HTMLpurifier library, and I was able to run the PurifierTest.pl script which calls the basic.php script. But I had to comment out the use DateTime; directive in the perl script. So if I can just get that module properly installed I'll be in business.

But in the basic.php script I used backslashes as follows: require_once '..\library\HTMLPurifier.auto.php'; However I changed them back to "/" and it was still OK. The thing that I needed was the relative path '../'.

It's getting there. I think the PHP scripts may need to be in the SCGBG folder but maybe not. There were a lot of problems and I probably can restore some of what I changed to keep the scripts almost identical, except possibly for the "shebang". And I'm not sure why the Perl executable module could not be placed in the path /usr/bin/perl -T.
PStechPaul
 
Posts: 7
Joined: 22. January 2011 02:38

Re: Can't access cgi-bin folder

Postby PStechPaul » 22. January 2011 10:14

Update: I had to install these modules (found in the German Perl forum):

Code: Select all
ppm install DateTime
ppm install DateTime-TimeZone
ppm install Template-Toolkit

and also
Code: Select all
ppm install List-MoreUtils


I can get some things to work, but it seems that there are problems with a PHP script in the cgi-bin directory or a perl script which is not in that directory. Or something like that. The perl script and the PHP script can't seem to write files in the SCGBG folder, but they won't run properly in the cgi-bin folder. I have a simple demo that works fine with a perl script that calls a PHP script in the SCGBG folder, but it only writes to stdin. The same demo in the cgi-bin folder shows a server error, but the files are written there OK.
Last edited by PStechPaul on 22. January 2011 11:05, edited 1 time in total.
PStechPaul
 
Posts: 7
Joined: 22. January 2011 02:38

Re: Can't access cgi-bin folder

Postby Sharley » 22. January 2011 11:03

But I also tried running my "basic.php" script, and it complained that it must start with "#!". I did so, and I got a differfent error:
Paul not 100% sure about this as I have not had the need to use it but as you are needing this you might like to try it see what it does for you.

The shebang at the top of a php script that you want to run in the cgi-bin may look like this as it has to use the php-cgi interpreter not the normal php interpreter:
Code: Select all
#!"C:\xampp\php\php-cgi.exe"
very much like the perl shebang.

Thanks also for keeping the forum informed of your progress on this issue, that's very helpful for others with this issue.

There could be a more experienced member spot your topic and lend a hand to have you moving forward.

Sorry I could not be more help.

Good luck and best wishes.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 124 guests