0

On my Mac OSX 10.7.4 with Perlbrew's Perl-5.16.0 I have this nginx.conf:

server {
   listen 1234;
   server_name MyPHPPerlServer;
   root "/Library/WebServer/servdir"; 

location / {
fancyindex on;
}

location ~ \.php$ {
         fastcgi_pass  127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
         include fastcgi_params;
         }

location ~ \.pl$ {
         try_files $uri =404;
         gzip off;
     #fastcgi_pass  127.0.0.1:8999;
         fastcgi_index index.pl;
         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
         include fastcgi_params;
         } 
}

For this configuration to run the PHP scripts, I compiled and ran php-fpm, and it runs PHP fine now.

To run the Perl scripts, I compiled nginx with ./configure --add-module=../ngx-fancyindex --with-http_perl_module and nginx runs fine with this configuration but when I browse to http://localhost:1234/index.pl it doesn't execute the Perl script, it just downloads it.

As a check, I shut down the nginx and start Apache with the cgi_module on and it runs the index.pl perfectly.

What should I do to make nginx run the Perl scripts? Thank you.

1
  • You don't use any http_perl_module features??? Commented Feb 23, 2017 at 14:54

1 Answer 1

1

The scripts are being sent to the browser because that's the default manner in which request files are handled, and you don't override this (say by using fastcgi_pass). Please follow the instructions.

Sign up to request clarification or add additional context in comments.

5 Comments

If I enable that line, it gives: 502 Bad Gateway so I disabled that line.
Is your FCGI daemon running? Is it listening at 127.0.0.1:8999? Or did you stop halfway through the instructions. Or if the daemon is running, it could be that your script isn't sending a response (in which case you should check the fcgi damon's error log).
I tried to run FCGI daemon by entering ./perl-fcgi start but it returned: Can't load '/Users/<shortened>/darwin-2level/auto/FCGI/FCGI.bundle' for module FCGI: <...> Symbol not found: _PL_curcop <...> Compilation failed in require at /usr/bin/fastcgi-wrapper.pl line 4. I installed FCGI with cpanm so it's up to date. (0.78)
Hello, the problem turned out to be the missing daemon called fastcgi-wrapper.pl as stated on the instructions page you've given. I've installed a shell script called perl-fcgi on nginx folder and the fastcgi-wrapper.pl on /usr/bin and nginx works with perl now. Problem's solved but if you only post an updated answer I can select it as the solution. Thanks.
I can't add it to my Answer because that's not the solution the Question you posted; that's the solution to the question you asked in the comments. As for the question you asked in the comments, I answered it almost a month ago. As you just confirmed now, the problem was that you hadn't followed the instructions all the way through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.