0
我終於爾康+ phpfpm + nginx的在OSX工作...試圖建立一個快速的REST應用我堅持,我相信有一個nginx的重寫。爾康+ Nginx的路由/重寫不工作
我總是得到一個路徑不匹配的錯誤。
文件結構:
/myapp/
public/
index.php
app/
models/
...
的index.php
<?php
$app = new \Phalcon\Mvc\Micro();
$app->get('/api/robots', function() {
echo json_encode(['true']);
});
$app->notFound(function(){
echo json_encode(['Route Not Found']);
});
$app->handle();
nginx的配置文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
root /var/www/bmex/public;
listen 80;
server_name some.name.com;
charset utf-8;
#access_log /var/log/nginx/host.access.log main;
set $root_path '/var/www/bmex/public';
location/{
root $root_path;
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_index /index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
}
}
它出現的問題是_uri快到了雙斜槓......所以真正的路線// API /機器人......現在發現它爲什麼被添加額外的斜槓..以及如何將其刪除。 – smorhaim 2014-09-11 03:45:46