server {
listen 80;
server_name localhost.dev;
index index.php index.html index.htm;
set $root_path '/www/test.xxx.com/public';
root $root_path;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.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 ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
index.php
<?php error_reporting(E_ALL); use Phalcon\Loader; use Phalcon\Mvc\View; use Phalcon\Mvc\Url as UrlProvider; use Phalcon\Mvc\Application; use Phalcon\DI\FactoryDefault; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter; try {
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(array(
'../app/controllers/',
'../app/models/'
))->register();
// Create a DI
$di = new FactoryDefault();
// Setup the view component
$di->set('view', function(){
$view = new View();
$view->setViewsDir('../app/views/');
return $view;
});
$di->set('db', function(){
return new DbAdapter(array(
"host" => "localhost",
"username" => "mysql",
"password" => "1234",
"dbname" => "****",
"charset" => "utf8"
));
});
// Setup a base URI so that all generated URIs include the "tutorial" folder
$di->set('url', function(){
$url = new UrlProvider();
$url->setBaseUri('/');
return $url;
});
// Handle the request
$application = new Application($di);
echo $application->handle()->getContent();
} catch(\Exception $e) { echo "PhalconException: ", $e->getMessage(); }
I encountered a problem, when I visited test.xxx.com cannot jump to the index controller, the page is blank, but I visit test.xxx.com/Index/inde is there is no problem, what reason is this excuse me?