DevHeads.net

How to start perl script using FCGID module

Hi,

I am trying to run a perl script using fcgid module.
I have loaded mod_fcgid module.

I have created a directory in apache called fcgi-bin and added the below
snippet to my httpd.conf file.
<Directory '/home/ananya/apache-http-connector/apache-2.4.29/fcgi-bin/'>
AddHandler fcgid-script .pl
AllowOverride All
Options +Indexes +FollowSymLinks +ExecCGI
Require all granted
</Directory>

And have also added -
ScriptAlias /fcgi-bin/
'/home/ananya/apache-http-connector/apache-2.4.29/fcgi-bin/'

My perl program is a simple hello world programme as follows-

#!/usr/bin/perl
print("Content-Type: text/plain\n\n");
print "Hello world";

But the problem that I am facing is that the 'Hello World' output is
getting printed in my Apache error logs and not in the browser as a perl
script. Can someone please help me out with this?

Thanks
Ananya

Comments

Re: How to start perl script using FCGID module

By Yehuda Katz at 08/09/2018 - 08:20

The difference between FastCGI and regular CGI is that regular CGI runs the
program directly and FastCGI is expected to run continuously and handle
requests. If you want to use FastCGI in Perl, you might want to start with
a library like PSGI or a framework like Catalyst.

- Y

Sent from a device with a very small keyboard and hyperactive autocorrect.

Hi,

I am trying to run a perl script using fcgid module.
I have loaded mod_fcgid module.

I have created a directory in apache called fcgi-bin and added the below
snippet to my httpd.conf file.
<Directory '/home/ananya/apache-http-connector/apache-2.4.29/fcgi-bin/'>
AddHandler fcgid-script .pl
AllowOverride All
Options +Indexes +FollowSymLinks +ExecCGI
Require all granted
</Directory>

And have also added -
ScriptAlias /fcgi-bin/
'/home/ananya/apache-http-connector/apache-2.4.29/fcgi-bin/'

My perl program is a simple hello world programme as follows-

#!/usr/bin/perl
print("Content-Type: text/plain\n\n");
print "Hello world";

But the problem that I am facing is that the 'Hello World' output is
getting printed in my Apache error logs and not in the browser as a perl
script. Can someone please help me out with this?

Thanks
Ananya

Re: How to start perl script using FCGID module

By Ananya Dey at 08/09/2018 - 11:51

Thanks for the response Yehuda Katz :)
Also, to run python scripts we need to use the WSGI module. So how do we
implement that with mod_fcgid?

Regards
Ananya

Re: How to start perl script using FCGID module

By Yehuda Katz at 08/09/2018 - 12:15

WSGI doesn't work with FastCGI by itself. You can use mod_wsgi, a
wsgi->fastcgi wrapper like flup, or change your program to use fcgiapp or
python-fastcgi.
I think the Flask documentation has some good details and examples:
<a href="http://flask.pocoo.org/docs/1.0/deploying/" title="http://flask.pocoo.org/docs/1.0/deploying/">http://flask.pocoo.org/docs/1.0/deploying/</a>

- Y

Re: How to start perl script using FCGID module

By Stormy at 08/09/2018 - 12:14

On 2018-08-09 12:51 PM, Ananya Dey wrote:
You don't need any *cgi* -- just a2enmod wsgi.conf, works like a dream :=}

Paul