2017-02-23 45 views
0

在我的Mac OSX 10.7.4與Perlbrew的Perl的5.16.0我有這個nginx.confnginx的與http_perl_module不執行Perl腳本只是下載它們

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; 
     } 
} 

對於這個配置來運行PHP腳本,我編譯並運行php-fpm,現在它運行PHP很好。

要運行Perl腳本,我 ./configure --add-module=../ngx-fancyindex --with-http_perl_module nginx的編譯和運行Nginx的罰款與此配置,但是當我瀏覽到http://localhost:1234/index.pl它不執行Perl腳本,它只是下載它。

作爲一個支票,我關閉了nginx並啓動了Apache,啓動了Apache,並啓動了Apache,並且它完全運行了index.pl。

我應該怎麼做才能讓nginx運行Perl腳本?謝謝。

+0

你不使用任何http_perl_module功能? – ikegami

回答

1

腳本正在發送到瀏覽器,因爲這是處理請求文件的默認方式,並且您不會覆蓋此內容(通過使用fastcgi_pass)。請按照instructions

+0

如果我啓用該行,則會發出:502 Bad Gateway,因此我禁用了該行。 – Romario

+0

您的FCGI守護進程是否正在運行?它是在'127.0.0.1:8999'聽嗎?或者你是否停止了[說明]的一半(http://nginxlibrary.com/perl-fastcgi/)。或者如果守護進程正在運行,那可能是您的腳本沒有發送響應(在這種情況下,您應該檢查fcgi damon的錯誤日誌)。 – ikegami

+0

我試圖通過輸入./perl-fcgi start來運行FCGI守護程序,但它返回:無法爲模塊FCGI加載'/ Users/ /darwin-2level/auto/FCGI/FCGI.bundle':<...>未找到符號: _PL_curcop <...>編譯在/usr/bin/fastcgi-wrapper.pl第4行的require中失敗。我使用cpanm安裝了FCGI,因此它是最新的。 (0.78) – Romario