nginx - 无法加载具有正确的( ) include_path的ZF2?

  显示原文与译文双语对照的内容
0 0

所以,我对所有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

这是我的/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_path就像这样在/etc/php5/fpm/php.ini 中:

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

这是 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

这是正确的库文件夹?

这是我的/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!
ZendMvcApplication::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"
时间:原作者:2个回答

0 0

解决问题如果你遇到这样的问题,请像这样在fastcgi_params中定义你的ZF2_PATH: !

fastcgi_param ZF2_PATH/var/www/testing.dom/public_html/library/;
原作者:
...