您的位置:首页 > 运维架构 > Nginx

PHP slim restfull框架nginx 配置

2014-05-19 23:08 597 查看
http://docs.slimframework.com/ 下载地址这个东西很不错,照到官方的例子做

<?php

require 'vendor/autoload.php';

$app = new \Slim\Slim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->run();


访问localhost/index.php/hello/adaaa 怎么都报404错误

后面想了一下,要支持伪静态.

Nginx 设置是

root        /Users/jackluo/Works/php/rest;

location / {
root    /Users/jackluo/Works/php/rest;
index   index.html index.php;
try_files $uri $uri/ /index.php?$args;
}


Apache 设置是

【1】启动mod_rewrite——去掉#,#代表注释
LoadModule rewrite_module modules/mod_rewrite.so

【2】修改AllowOverride None为AllowOverride All
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride All
Require all granted
</Directory>


这样再访问:

就有值了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: