无法找到用户登录页面

时间:2016-10-28 20:26:56

标签: php nginx zend-framework

尝试运行Zend应用程序,我在应用程序文档根请求上获得了404。

这个是由Zend框架的/Application/view/errors/404.php页面呈现的,而不是服务器404页面。

我在我的Linux机器上安装了Nginx和php-fpm以及MariaDB来运行这个Zend应用程序。

我将php执行附加到PHP Eclipse XDebug调试器,该调试器显示正在运行的index.php页面,直至其Zend\Mvc\Application::init调用。

// Setup autoloading
require 'init_autoloader.php';

// Run the application!
Zend\Mvc\Application::init(require 'config/application.config.php')->run();

我已配置Nginx虚拟主机:

$ cat programs/install/nginx/conf/sites-available/nginx-dev.extrapack.my-group.com 
server {
  listen 80;
  server_name dev.extrapack.my-group.com;
  root   /home/stephane/dev/php/projects/my/Extrapack-Mon/public;
  index index.php;
  include /home/stephane/programs/install/nginx/conf/security;

  access_log  /home/stephane/programs/install/nginx/logs/access.log;
  error_log  /home/stephane/programs/install/nginx/logs/error.log notice;

  location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
    access_log        off;
    log_not_found     off;
    expires           max;
  }

  location ~ \.php$ {
    try_files $uri = 404;
    fastcgi_index index.php;
    fastcgi_pass php5-fpm-sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param HTTPS 'on'; # Make PHP-FPM aware that this vhost is HTTPs enabled
    fastcgi_param APPLICATION_ENV development;
    include fastcgi_params;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
  }

  client_max_body_size 20m;
  client_body_buffer_size 128k;
}

/Application/config/module.config.php文件包含:

    'application' => array(
        'type'    => 'Literal',
        'options' => array(
            'route'    => '/application',
            'defaults' => array(
                '__NAMESPACE__' => 'Application\Controller',
                'controller'    => 'Index',
                'action'        => 'index',
            ),
        ),

但是IndexController根本没有被击中,调试器不会停在控制器的任何断点处。

我在onBootstrap回调中添加了此代码块:

$em->attach('dispatch.error', function($e){
    switch ($e->getError()) {
        case 'error-router-no-match':
            break;
    }
}, -100);

并且调试器会在break;行的断点处停止,这意味着错误为error-router-no-match

以下是我运行调试配置时调试器请求的url: http://dev.extrapack.group.com/index.php?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=14776859837352

作为Zend noob,我不知道还能为您提供哪些帮助,但如果我的问题中缺少某些配置,我很乐意添加它。

我在Zend 2.4.9版上。

编辑:我添加了一个SSL虚拟主机,使应用程序最终能够显示其用户登录页面,从而解决了这个问题。

server {
  listen 443;
  server_name dev.extrapack.group.com;
  root /home/stephane/dev/php/projects/Extrapack-Mon/public;
  ssl on;
  ssl_certificate /home/stephane/programs/install/nginx/conf/sites-available/extrapack.group.com.crt;
  ssl_certificate_key /home/stephane/programs/install/nginx/conf/sites-available/extrapack.group.com.key;

  location /simplesaml {
    index index.php;
    alias /usr/share/simplesaml/www;
    location ~ ^/simplesaml/(module\.php)(/.+)$ {
      include fastcgi_params;
      fastcgi_pass php5-fpm-sock;
      fastcgi_split_path_info ^/simplesaml/(module\.php)(/.+)$;
      fastcgi_param SCRIPT_FILENAME /usr/share/simplesaml/www/$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_index index.php;
    }
    location ~ \.php$ {
      include fastcgi_params;
      fastcgi_pass php5-fpm-sock;
    }
  }

  location / {
    include fastcgi_params;
    fastcgi_pass php5-fpm-sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    try_files $uri /index.php?$args;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param HTTPS 'on'; # Make PHP-FPM aware that this vhost is HTTPs enabled
    fastcgi_param APPLICATION_ENV development;
    fastcgi_index index.php;
  }
}

1 个答案:

答案 0 :(得分:1)

您的网址应映射为http://dev.extrapack.group.com作为http服务器上的默认路径,而不是http://dev.extrapack.group.com/index.php