Changing the path to perl to conform to the cgi script

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

Changing the path to perl to conform to the cgi script

Postby sborder » 14. February 2009 08:14

I have xampp and the perl addon installed. It's working but I need to change the path to perl to #!/usr/bin/perl instead of #!"G:\usr\perl\bin\perl.exe".

This is a test server and all of the scripts that I work with have #!/usr/bin/perl as the shebang line. So it's important to keep that line the same in the scripts.

This is on my windows xp sp2 pc.

I'm not quit sure where to go from here.

Thnks
Steve
User avatar
sborder
 
Posts: 19
Joined: 31. January 2007 08:06
Location: Iowa, USA
Operating System: linux mint 12, xppro and 7

Re: Changing the path to perl to conform to the cgi script

Postby Izzy » 14. February 2009 08:44

I found this in my KB from an earlier post which may seed some ideas:
viewtopic.php?p=116505#p116505
Izzy's KB wrote:Hi, I had a suggestion for a better place for XAMPP to install Perl. I
am sure this has been suggested before but C:/usr/bin/perl is the better
idea than C:/xampp/perl. I personally created a usr in C:/ folder and
moved my perl folder from C:/xampp/perl to C:/usr and it helped me a
lot.

In Perl/CGI, you have to do

#!/usr/bin/perl
for Linux and most other servers on the web, so what you would have to
do with XAMPP is

#!/xampp/perl
which makes things a whole lot harder when you're using XAMPP for
testing code on your home computer just to upload it to your actual web
server later as I do.
You may have to use #!usr/bin/perl.exe which will work with XAMPP and your remote server if you follow the above idea.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Changing the path to perl to conform to the cgi script

Postby sborder » 14. February 2009 14:09

Believe it or not, I had moved the bin directory up one level so the path would be correct. But then I tried the xampp control panel and I was not able to start the aphache server.

But I will look at this again.
Will let you know.

Thanks
Steve
User avatar
sborder
 
Posts: 19
Joined: 31. January 2007 08:06
Location: Iowa, USA
Operating System: linux mint 12, xppro and 7

Re: Changing the path to perl to conform to the cgi script

Postby Izzy » 14. February 2009 14:14

If Apache won't start then run apache_start.bat file and see the message returned, it will hold the clue.

Also check out the apache\logs\error.log file.

May be you would need to remove perl and reinstall the addon again to the new location as there is a perl.conf and a startup.pl file in the apache\conf\extra folder that may have to be edited or deleted to reflect your new location - I have not tested this hack but I was assured that it worked, experiment and see how it pans out.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Changing the path to perl to conform to the cgi script

Postby Wiedmann » 14. February 2009 15:20

I had moved the bin directory up one level so the path would be correct.

Revert this change.

This is a test server and all of the scripts that I work with have #!/usr/bin/perl as the shebang line. So it's important to keep that line the same in the scripts.

http://httpd.apache.org/docs/2.2/mod/co ... etersource
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Changing the path to perl to conform to the cgi script

Postby Izzy » 14. February 2009 23:11

@Steve

Please move the bin folder back to where it was originally before attempting the below test.


I decided to test the above hack for myself so I could confirm what had already been established, that it indeed worked.
(Your paths may be different so adjust as required).


1. First I copied the contents of the G:\xampp\perl folder to a newly created G:\usr folder.

2. Renamed the G:\xampp\perl folder to G:\xampp\perladdon

3. Changed the path in G:\xampp\apache\conf\extra\perl.conf file from /xampp/perl to /usr on the first line only.

4. Change the shebang in G:\xampp\cgi-bin\perltest.cgi from #!"G:\xampp\perl\bin\perl.exe" to #!/usr/bin/perl.exe

5. Started Apache - it started without errors.

6. Went to http://locahost/cgi-bin/perltest.cgi

The perltest.cgi worked as expected and returned the expected script's contents:
CGI with MiniPerl
CGI with MiniPerl is ready ...


7. I then tested it with several of my production cgi scripts after changing the shebang and all worked as expected at localhost - not tested on a remote server but they should work fine as the shebang is now the same as for a remote apache server.


So after testing the above I can see no reason at this time that it would not work for you.

Let me know if you can follow the above and if it worked for you with the result that you was seeking.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Changing the path to perl to conform to the cgi script

Postby sborder » 15. February 2009 00:02

Izzy - Thanks !! It works great.

The only difference was that I already had xampp installed in the "G:/usr" directory.
I just changed the directory when I used the installer.

Now if this could become an option when installing it would save some mionr main. :)

Anyway thanks, your help is appreciated.

Steve
User avatar
sborder
 
Posts: 19
Joined: 31. January 2007 08:06
Location: Iowa, USA
Operating System: linux mint 12, xppro and 7

Re: Changing the path to perl to conform to the cgi script

Postby Wiedmann » 15. February 2009 00:11

Izzy - Thanks !! It works great.

I hope you will never update XAMPP and the Perl AddOn... (you must copy Perl every time you update XAMPP) But fine it's working for you :-)

As I post above above:
The preferred way (from apache.org) is to use ScriptInterpreterSource (one line in "httpd.conf" and one entry in the Windows registry). Or just make a symlink (no other changes are necessary) .
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Changing the path to perl to conform to the cgi script

Postby sborder » 15. February 2009 00:58

I am unsure of playing in the registry. This is on my good pc and I would hate to mess things up. But I do agree your way would be better and if I had more experience with the registry I might try your way.

I am going to setup a test server (for agoracart) with a different box in a couple of months, so this is just a temporary fix.

Thanks
Steve
User avatar
sborder
 
Posts: 19
Joined: 31. January 2007 08:06
Location: Iowa, USA
Operating System: linux mint 12, xppro and 7

Re: Changing the path to perl to conform to the cgi script

Postby Wiedmann » 15. February 2009 01:04

I am unsure of playing in the registry.

It's just a simple file association, which you can also make in explorer. Nothing special.

(Making it in the registry it's just easier to explain for me, because I don't know the English explorer menu names.)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 48 guests