Using any Perl script with FastCGI (Experimental)

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
aprelium-beta
-


Joined: 24 Jun 2004
Posts: 383

PostPosted: Fri Jun 09, 2006 5:11 pm    Post subject: Using any Perl script with FastCGI (Experimental) Reply with quote

Here is a quick and experimental add-on to offer FastCGI speed to any Perl script (without requiring it to be modified):

* Download http://www.aprelium.com/data/PerlFCGI.zip and uncompress it inside your Abyss Web Server installation directory inside a subdirectory named PerlFCGI
* Follow all setup instructions in http://www.aprelium.com/abyssws/perl.html but apply these two differences:
- Set Interface to "FastCGI (Local - Pipes)" or "FastCGI (Local - Pipes)" instead of "CGI/ISAPI"
- After locating the perl executable, set the "Arguments" field to:
Code:
-I"C:\\Program Files\\Abyss Web Server\\PerlFCGI" "C:\\Program Files\\Abyss Web Server\\PerlFCGI\\run.pl"


Note that you should substitute in the example above C:\\Program Files\\Abyss Web Server\\ with your actual path of Abyss Web Server installation directory.

Note also that you'll have to use two back slashes \\ instead of single backslash \ in path names (this is required in the arguments line).

If you use forward slashes /, there is no need to double them in the arguments line.

With such a setup, .pl and .cgi scripts will use FastCGI interface instead of CGI. There is no need to change anything in their source code.

Here is simple test.pl for testing purposes:

Code:
use CGI qw/:standard/;

print header,
    start_html('A Simple Example'),
    h1('A Simple Example'),
    start_form,
    "What's your name? ",textfield('name'),p,
    "What's the combination?", p,
    checkbox_group(-name=>'words',
                   -values=>['eenie','meenie','minie','moe'],
                   -defaults=>['eenie','minie']), p,
    "What's your favorite color? ",
    popup_menu(-name=>'color',
               -values=>['red','green','blue','chartreuse']),p,
    submit,
    end_form,
    hr;

if (param()) {
   print "Your name is",em(param('name')),p,
         "The keywords are: ",em(join(", ",param('words'))),p,
         "Your favorite color is ",em(param('color')),
         hr;
}


We'll be waiting for your feedback on this add-on (which is a quick hack and not fully tested).
_________________
Beta Testing Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sat Jun 10, 2006 2:11 am    Post subject: Reply with quote

Hi Aprelium.

Thanks for looking hard into this problem and providing the hack.
I am glad to say it works!!! :D
I have been busily trying to get my regular CGI scripts to work with FastCGI.

Here are a few pointers:

  • Every script is running in strict mode, whether your script says so or not - because run.pl specifies this.
  • If you need to initialize multiple variables at one time, you can do so by
    Code:
    my ($a, $b, $c, $d, $e);

  • If your Perl distribution is from ActiveState (ActivePerl), you probably do not have fcgi.pm installed (I did not). It is necessary for FastCGI.
  • You can obtain fcgi.pm by going to your perl/bin/ directory and typing
    Code:
    ppm.bat
    search fcgi
    install 1
    exit

  • You might need to copy persistent.pm into your perl/lib/ folder, as I did.


Here's a little quirk. If you run your script in your browser, you might receive the following:
Quote:
Perl Error in FILENAME

If you do, simply refresh your browser for detailed information concerning the error. You will most likely find something like
Quote:
Global symbol "@DoW" requires explicit package name at (eval 14) line 4.

This simply means you must initialize all of your variables.
________________________
I'll let you know if I stumble across any problems concerning FastCGI.

Aprelium, thanks again. I appreciate your hard work.
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Jun 10, 2006 4:31 pm    Post subject: Reply with quote

pkSML,

Thank you for the comments and the quick feedback. We'll fix the problems you have reported.

By the way, why was it necessary to copy Persist.pm in your Perl Lib directory? The purpose of -I"C:\\Program Files\\Abyss Web Server\\PerlFCGI" in the arguments field was exactly to avoid such a manual copying operation...
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
pkSML
-


Joined: 29 May 2006
Posts: 952
Location: Michigan, USA

PostPosted: Sat Jun 10, 2006 8:54 pm    Post subject: persistent.pm Reply with quote

Hi Aprelium.

I tried running run.pl yesterday from the command line, but it said it couldn't find persistent.pm in the @INC array. So I just copied the file to one of the directories it listed for the @INC array.
I just re-ran run.pl, and it turns out I don't need it. Sorry. :oops:
_________________
Stephen
Need a LitlURL?


http://CodeBin.yi.org
Back to top View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sat Sep 16, 2006 11:51 am    Post subject: Reply with quote

Instead of having to manually install FCGI from the PPM utility and copying so
many different files to other locations, I decided to create my own little version
of this for everyone to use. This is a very easy setup to follow.

Perl FastCGI (Permanent Setup)
http://www.trustabyss.com/perl_fastcgi.html

Sincerely, TRUSTAbyss
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Sep 16, 2006 12:45 pm    Post subject: Reply with quote

TRUSTAbyss,

Thank you for the contribution. A minor remark though: the sample we've included, and which you've credited as ours, was not created by us. :-)
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sun Sep 17, 2006 1:36 am    Post subject: Reply with quote

I just updated it so it doesn't say who the script is from. I had some trouble with
AWStats while using this method though. Here's the error I get.

FastCGI.localhost.conf couldn't be opened.

When I use Standard CGI it works fine. Is the arguments being taken as part
of the configuration for AWStats? it's weird. :/
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sun Sep 17, 2006 3:16 pm    Post subject: Reply with quote

TRUSTAbyss,

Some scripts may be incompatible with this FastCGI starter. Which version of AWStats have you used?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sun Sep 17, 2006 5:04 pm    Post subject: Reply with quote

I'm using version 6.5
Back to top View user's profile Send private message Visit poster's website
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Sep 18, 2006 3:37 pm    Post subject: Reply with quote

TRUSTAbyss wrote:
I'm using version 6.5


Thanks, we'll give it a try to check what the problem is.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Immemiaplaype
-


Joined: 13 Jul 2011
Posts: 13
Location: United Kingdom

PostPosted: Sun Jan 22, 2012 10:48 pm    Post subject: Using any Perl script with FastCGI Experimental Reply with quote

Hi everyone,

I am starting to learn Perl and have had a little difficulty. The start of my problem was the Shebang line.

Its the first line of a Perl program and starts out with #. The # indicates a comment, but the following turns it into a perl directive. It is followed by /usr/bin/perl .

The line would look like:

#/usr/bin/perl

Great, this is fine It will work in Perl in MS/DOS windows, PerlMac, raw Unix and Linux and Apache servers on Unix and Linux

However, when you run it on Apache on your own PC, you may have to change this line.

I have Apache2Triad installed on my PC. The correct Shebang line for it is:

#C:/apache2triad/perl/bin/perl.exe

This path to Perl is listed in the apache2triad Control Program, on the lower left of the screen. If youre just starting out with perl and your programs arent working, check this line out, for "your server" first

Bill
Back to top View user's profile Send private message Send e-mail ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group