Php 我将如何使用Nginx+;在运行/api/的Windows上安装Slim?

Php 我将如何使用Nginx+;在运行/api/的Windows上安装Slim?,php,mysql,windows,nginx,slim,Php,Mysql,Windows,Nginx,Slim,已编辑,因为它现在可以工作: 检查下面的代码 我有一个使用Debian 7的完整环境+Nginx+Slim+PHP+MySQL 结构如下: 根 |----原料药 |----应用程序 |--- |---文件 等 我在根目录下有index.html,然后在/api子目录下有index.php 我在LinuxDebian中的路由工作得很好。 一切都在Linux中运行 现在。。。 我必须让它在windows中也能正常工作。(是的,我知道……不知道) 因此,我有一个名为agil.windows.ft的

已编辑,因为它现在可以工作: 检查下面的代码

我有一个使用Debian 7的完整环境+Nginx+Slim+PHP+MySQL 结构如下:

  • |----原料药
  • |----应用程序
  • |---
  • |---文件

我在根目录下有index.html,然后在/api子目录下有index.php

我在LinuxDebian中的路由工作得很好。 一切都在Linux中运行

现在。。。 我必须让它在windows中也能正常工作。(是的,我知道……不知道)

因此,我有一个名为agil.windows.ft的本地域(在windows中的主机文件中设置)

我所有的nginx/mysql/php都在我的windows8.1机器上运行 我建立了同样结构的网站

在debian中,根目录位于/home/development/[siteroot] 在windows中,它位于c:\WebSites[siteroot]

我可以运行网站,我可以去

agil.windows.ft/api/并获得回复(请查看帖子末尾)

但我不能打电话,例如

agil.windows.ft/api/info(路由以显示phpinfo())

当它返回404错误时

NGINX中我的DEBIAN agil配置文件是:

server {
listen          80; ## listen for ipv4
server_name     agil.debian.ft;
root            /home/developing/agil;

access_log      /var/log/www/agil.access.log;
error_log       /var/log/www/agil.error.log;

index           index.html index.php;

## Support for favicon. Return a 204 (No Content) if the favicon
## doesn't exist.
location = /favicon.ico {
        try_files /assets/img/favicon.ico =204;
}

//COMMENTED THE FOLLOWING LINE
**#try_files /api/$uri $uri/ /api/index.php?$request_uri;**
// AND IT WORKS

location /api/ {
    try_files /api/index.php =404;

    fastcgi_pass 127.0.0.1:8000; 
    include /etc/nginx/fastcgi_params;
    fastcgi_split_path_info ^/api/(.+\.php)(/.+)$;
    fastcgi_intercept_errors on;
    include /etc/nginx/fastcgi_params;
fastcgi_read_timeout 3600;
}
}

windowsNGINX中不断尝试之后,我现在拥有的是:

server {
listen          80; ## listen for ipv4
server_name     agil.windows.ft;
root            c:\WebSites\agil;    
access_log      logs/agil.access.log;
error_log       logs/agil.error.log;

index           index.html index.php;

## Support for favicon. Return a 204 (No Content) if the favicon
## doesn't exist.
location = /favicon.ico {
        try_files /assets/img/favicon.ico =204;
}

#try_files /api/$uri $uri/ /api/index.php?$request_uri;

location /api/ {
        include fastcgi.conf;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        try_files /$uri $uri/ /index.php?$request_uri;
        fastcgi_pass 127.0.0.1:8000;
        fastcgi_split_path_info ^/api/(.+\.php)(/.+)$;
        fastcgi_intercept_errors on;
        fastcgi_index  index.php;
}
}

底线:

有人能帮忙吗

多谢各位

FT


agil.windows.ft的结果是:

API 1.0 - B2B

Agil V1Slim\Environment Object

(

    [properties:protected] => Array

        (

            [REQUEST_METHOD] => GET

            [REMOTE_ADDR] => 127.0.0.1

            [SCRIPT_NAME] => /api

            [PATH_INFO] => /

            [QUERY_STRING] => 

            [SERVER_NAME] => agil.windows.ft

            [SERVER_PORT] => 80
            [COOKIE] => PHPSESSID=7pqv1re0pgd2m5lu412a1ejb74
            [ACCEPT_LANGUAGE] => pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
            [ACCEPT_ENCODING] => gzip, deflate, sdch
            [USER_AGENT] => Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
            [ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
            [CONNECTION] => keep-alive
            [HOST] => agil.windows.ft
            [CONTENT_LENGTH] => 
            [CONTENT_TYPE] => 
            [slim.url_scheme] => http
            [slim.input] => 
            [slim.errors] => Resource id #20
            [slim.log] => Slim\Log Object
                (
                    [writer:protected] => Slim\LogWriter Object
                        (
                            [resource:protected] => Resource id #20
                        )
                        [enabled:protected] => 1
                    [level:protected] => 4
                )
            [ApiDir] => C:\Websites\Agil/api

试试“root c:/WebSites/agil;”,日志文件怎么说这个404+禁用/api/中的try_文件,看看会发生什么。大家好。谢谢你的提示。我试过了,但没有成功。最后,我禁用了/api/location和/api/info之外的try文件。但是包含的路由文件中的所有其他文件都没有。。。类似于应该在不同的PHP文件中定义的/api/reports/summary。但那是因为目录分隔符。所以现在一切都好了。谢谢
API 1.0 - B2B

Agil V1Slim\Environment Object

(

    [properties:protected] => Array

        (

            [REQUEST_METHOD] => GET

            [REMOTE_ADDR] => 127.0.0.1

            [SCRIPT_NAME] => /api

            [PATH_INFO] => /

            [QUERY_STRING] => 

            [SERVER_NAME] => agil.windows.ft

            [SERVER_PORT] => 80
            [COOKIE] => PHPSESSID=7pqv1re0pgd2m5lu412a1ejb74
            [ACCEPT_LANGUAGE] => pt-PT,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2
            [ACCEPT_ENCODING] => gzip, deflate, sdch
            [USER_AGENT] => Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36
            [ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
            [CONNECTION] => keep-alive
            [HOST] => agil.windows.ft
            [CONTENT_LENGTH] => 
            [CONTENT_TYPE] => 
            [slim.url_scheme] => http
            [slim.input] => 
            [slim.errors] => Resource id #20
            [slim.log] => Slim\Log Object
                (
                    [writer:protected] => Slim\LogWriter Object
                        (
                            [resource:protected] => Resource id #20
                        )
                        [enabled:protected] => 1
                    [level:protected] => 4
                )
            [ApiDir] => C:\Websites\Agil/api