Welcome! Log In Create A New Profile

Advanced

Issues setting up Fastcgi for Perl

Posted by eltopo 
Issues setting up Fastcgi for Perl
April 17, 2014 10:06AM
So recently I decided to switch from Apache 2.4 to Nginx, largely for better performance. I also wanted to get a new site going that would be written in Perl and served by FastCGI, as well as support my current wordpress sites.

The PHP portion of the configuration was easy as pie. I installed and configured php-fpm, and after a few tweaks everything was working as before (except slightly faster). So far so good.

Perl hasn't been quite as easy to set up. I feel a bit like someone falling down a tree and getting his nuts smashed by every branch on the way down, if you'll pardon the expression. However I'm now at a point where I've tried every fix for my remaining problem and the test page is still not up and running.

My setup is as follows: Amazon Linux AMI running in EC2, have installed nginx, perl and spawn-fcgi from the repository, have compiled and installed fcgiwrap.

Nginx, php-fpm, and spawn-fcgi/fcgiwrap are all set to run as www-data:www-data and execute as daemons.

For the defined web roots I have made sure that all the directories all the way to root are o+x, and the web, log and other directories (e.g. /var/lib/nginx) themselves are owned by www-data:www-data. All FCGI requests are communicated through a socket file, both for php-fpm and fcgiwrap, although different sockets are used. Oddly enough the php-fpm socket appears to be owned by root:root while the fcgiwrap socket is owned by www-data:www-data. Things have been configured largely as per the instructions here:

http://www.howtoforge.com/serving-cgi-scripts-with-nginx-on-centos-6.0-p2

And still all I get when I try to hit my test page is "403: forbidden". It states just that in smallcaps -- View Source shows nothing else than that one line -- so this is not the standard NGINX error page. I have tried tailing the error log while making the request, but nothing gets added (like there's effectively no error), nor can I find anything relevant in /var/log/messages.

I'm getting to my wits' end trying to diagnose this. As I mentioned I've tried a lot of the fixes one can find with a google search, but nothing has resolved the issue so far. Can anyone suggest something I might be missing?
Re: Issues setting up Fastcgi for Perl
April 17, 2014 12:25PM
Hello,

It's been quite awhile since I've used Perl with nginx and t the time I used fcgiwrap - see https://nginx.localdomain.pl/wiki/FcgiWrap.

I have a (perhaps dumb) question. Is your Perl script executable? If not, that can cause a 403.

See if anything is in your access log related to those requests.

Change the severity of error logging. It's set to "error" by default but you may want something that provides more information. See http://nginx.org/en/docs/ngx_core_module.html#error_log.

Posting your config may help someone help you more than that.

--
Jim Ohlstein
Re: Issues setting up Fastcgi for Perl
April 17, 2014 01:54PM
I've set the debug level to "info" but there were no entries still.

Now, since then I dumped spawn-fcgi and configured fastcgi to operate standalone, according to these instructions:

http://wiki.nginx.org/Fcgiwrap

When I start the fcgi "daemon" and try and access the page I get this message in stderr:

"Cannot get script name, is
DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?"

which is at least a little helpful. The script is definitely executable but I guess I'll have to check for the two mentioned variables being set (I am at work and have limited access to my server ATM).
Re: Issues setting up Fastcgi for Perl
April 17, 2014 08:00PM
Those should be set as fastcgi_params either in the location where your "fastcgi_pass" statement is located, or in an included file.

Something like:

fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;

--
Jim Ohlstein
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready