使用Nginx+与Phalcon布线;php5 fpm,未找到文件

使用Nginx+与Phalcon布线;php5 fpm,未找到文件,nginx,routing,phalcon,Nginx,Routing,Phalcon,我一直在努力解决这个问题。我无法正确添加路由,否则nginx无法正确使用phalcon phalcon Tut都是基于apache的,这一点也没有帮助 问题:我可以访问http://localhost并且可以获得index.php,但是当我尝试访问localhost/signup时,会得到一个“未找到文件” index.php 试一试{ //Register an autoloader $loader = new \Phalcon\Loader(); $loader->registerDi

我一直在努力解决这个问题。我无法正确添加路由,否则nginx无法正确使用phalcon

phalcon Tut都是基于apache的,这一点也没有帮助

问题:我可以访问
http://localhost
并且可以获得index.php,但是当我尝试访问localhost/signup时,会得到一个“未找到文件”

index.php 试一试{

//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
    '../application/controllers/',
    '../application/models/'
))->register();

$di = new Phalcon\DI\FactoryDefault();

//Setup the view component
$di->set('view', function(){
    $view = new \Phalcon\Mvc\View();
    $view->setViewsDir('../application/views/');
    return $view;
});

$di->set('url', function(){
    $url = new Phalcon\Mvc\Url();
    $url->setBaseUri('/');
    return $url;
});

$di->set('router', function() {
    $router = new \Phalcon\Mvc\Router();
    $router->setUriSource(Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);
    $router->add(
        '/signup',
        array(
            "controller" => "signup",
            "action" => "index"
        )
    );

    return $router;
});

//Handle the request
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();

} catch(\Phalcon\Exception $e) {
  echo "PhalconException: ", $e->getMessage();
}
nginx配置

server {
listen   80;
server_name  Tikarta-berkshelf;
root /var/www/;
index public/index.php;
access_log  /var/log/nginx/localhost.access.log;

try_files $uri $uri/ @rewrite;

location @rewrite {
    rewrite ^/(.*)$ /index.php?_url=/$1;
}


location ~ \.php$ {
#try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index public/index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}

}
SignupController.php

<?php


class SignupController extends \Phalcon\Mvc\Controller
{

public function indexAction()
{
    echo "hello";
}

}

这里的问题是错误的文档根目录。Nginx config应该是

server {
    listen   80;
    server_name  Tikarta-berkshelf;
    root /var/www/public;
    index index.php;
    access_log  /var/log/nginx/localhost.access.log;

    location / {
    index  index.php index.html index.htm;

    # if file exists return it right away
    if (-f $request_filename) {
    break;
    }

    # otherwise rewrite it
    if (!-e $request_filename) {
    rewrite ^(.+)$ /index.php?_url=/$1 last;
    break;
    }
    }
    location ~ \.php$ {
    #try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/var/run/php5-fpm.sock;

    fastcgi_index index.php;
    include fastcgi_params;
    }
    location ~ /\.ht {
    deny all;
    }
}

通过发布一个问题,你会收到一部分来自外太空的精神能量射线,帮助你自己找到答案。事实。哈哈,是的,在我的工作中,当你试图向某人解释问题是什么时,这被称为橡皮鸭现象,而答案变得显而易见。你最好在办公桌上放一只橡皮鸭,然后问它。