Nginx 无法使用正确的(?)包含路径加载ZF2

Nginx 无法使用正确的(?)包含路径加载ZF2,nginx,zend-framework2,php,Nginx,Zend Framework2,Php,所以,我仍然是所有Unix方面的新手,现在我面临一个让我发疯的问题:)我也问了我的朋友,一个更有经验的程序员,但他也找不到答案。 所以,我尝试使用nginx和php5 fpm启动基于zend骨架的zf2应用程序 $ sudo service nginx status * nginx is running $ sudo service php5-fpm status php5-fpm start/running, process 3389 $ ps aux | grep php root

所以,我仍然是所有Unix方面的新手,现在我面临一个让我发疯的问题:)我也问了我的朋友,一个更有经验的程序员,但他也找不到答案。 所以,我尝试使用nginx和php5 fpm启动基于zend骨架的zf2应用程序

$ sudo service nginx status
 * nginx is running

$ sudo service php5-fpm status
php5-fpm start/running, process 3389

$ ps aux | grep php
root      3389  0.0  0.3 145520 13624 ?        Ss   15:40   0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)                    
www-data  3392  0.0  0.1 145520  4968 ?        S    15:40   0:00 php-fpm: pool www                                                       
www-data  3393  0.0  0.1 145520  5324 ?        S    15:40   0:00 php-fpm: pool www                                                       
somebud+  3551  0.0  0.0   5908   840 pts/1    S+   15:55   0:00 grep --color=auto php

$ ps aux | grep nginx
somebud+  3172  0.5  0.6 184412 24944 ?        Sl   15:33   0:07 gedit /etc/nginx/nginx.conf
root      3368  0.0  0.0  15196  1092 ?        Ss   15:40   0:00 nginx: master process /usr/sbin/nginx
www-data  3369  0.0  0.0  15720  2080 ?        S    15:40   0:00 nginx: worker process
www-data  3370  0.0  0.0  15376  1516 ?        S    15:40   0:00 nginx: worker process
www-data  3371  0.0  0.0  15376  1516 ?        S    15:40   0:00 nginx: worker process
www-data  3372  0.0  0.0  15376  1516 ?        S    15:40   0:00 nginx: worker process
somebud+  3554  0.0  0.0   5908   840 pts/1    S+   15:55   0:00 grep --color=auto nginx
这是my/etc/nginx/sites available/testing.dom

server {
      listen      80;
      server_name testing.dom;
      root /var/www/testing.dom/public_html/CommunicationApp/public/;
        index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ .*\.(php|phtml)?$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param APPLICATION_ENV development;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
    }

    location ~ .*\.(git|jpg|jpeg|png|bmp|swf|ico)?$ {
        expires 30d;
    }

    location ~ .*\.(js|css)?$ {
        expires 1h;
    }

    location ~ /\.ht {
        deny all;
    }
}
我的include_路径位于/etc/php5/fpm/php.ini中,如下所示:

; UNIX: "/path1:/path2"
include_path = ".:/usr/share/php:/var/www/testing.dom/public_html/library/Zend"
fastcgi_param  ZF2_PATH          /var/www/testing.dom/public_html/library/;
这是Zend文件夹中的内容:

$ sudo ls  /var/www/testing.dom/public_html/library/Zend/
    Authentication  Code     Db Escaper       Filter  InputFilter  Log     Mime       Paginator    Server          Stdlib  Uri    XmlRpc
    Barcode     Config   Debug  EventManager  Form    Json     Mail    ModuleManager  Permissions  ServiceManager  Tag     Validator
    Cache       Console  Di Feed          Http    Ldap     Math    Mvc        ProgressBar  Session         Test    Version
    Captcha     Crypt    Dom    File          I18n    Loader       Memory  Navigation     Serializer   Soap        Text    View
这是图书馆的文件夹吗

这是my/var/www/testing.dom/public_html/CommunicationApp/public/index.php

chdir(dirname(__DIR__));

$temp = get_include_path();
var_dump($temp);

// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
    return false;
}

// Setup autoloading
require '../CommunicationApp/init_autoloader.php';

// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();
所以,如果我在浏览器中输入testing.dom,我仍然会得到以下结果:

string(62) ".:/usr/share/php:/var/www/testing.dom/public_html/library/Zend" 
没有别的了

这是nginx error.log:

2014/10/17 16:11:29 [error] 3369#0: *8 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.' in /var/www/testing.dom/public_html/CommunicationApp/init_autoloader.php:53
Stack trace:
#0 /var/www/testing.dom/public_html/CommunicationApp/public/index.php(17): require()
#1 {main}
  thrown in /var/www/testing.dom/public_html/CommunicationApp/init_autoloader.php on line 53" while reading response header from upstream, client: 127.0.0.1, server: testing.dom, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "testing.dom"

问题解决了!如果您感到头痛,请尝试在fastcgi_参数中定义ZF2_路径,如下所示:

; UNIX: "/path1:/path2"
include_path = ".:/usr/share/php:/var/www/testing.dom/public_html/library/Zend"
fastcgi_param  ZF2_PATH          /var/www/testing.dom/public_html/library/;

问题解决了!