2015-10-28 128 views
1

我试图建立ngnix与它们所提供的结构的PhalconPHP框架教程:Nginx的配置

教程/的.htaccess

RewriteEngine on 
RewriteRule ^$ public/ [L] 
RewriteRule (.*) public/$1 [L] 

教程/公/.htaccess

AddDefaultCharset UTF-8 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] 

另一个文件夹是app其中共ntains文件夹:controllers,modelsviews。现在这个教程在apache上完美运行,但是在nginx上,我尝试了一些不起作用的规则。我ngnix的基本配置是:
服务器配置

server { 
    listen 80; 
    server_name localhost; 
    root C:/nginx/html; 
    location /tutorial { 
    rewrite ^/tutorial/(.*)$ /tutorial/public/$1 break; 
    try_files $uri $uri/ /tutorial/public/index.php?q=$uri&$args; 
    } 
    location /tutorial { 
     root C:/nginx/html; 
     index index.php; 
     rewrite ^/tutorial/(/.*)$ /public$1 break; 
     try_files $uri $uri/ /tutorial/public/index.php?$args; 
    } 
} 

任何人都可以请帮我在本教程中设置的位置上的规则,甚至nginx.I转换这些规则的.htaccess到nginx的规则在网上,但我不知道我错在哪里。

+0

我认为你的nginx配置在这里是不完整的,它有'location'语句吗?只有这两个部分?我建议你访问主文档[这里](https://docs.phalconphp.com/en/latest/reference/nginx.html)。 – M2sh

+0

没有那么完整,我刚刚给出了我的根路径。我只想知道我在phalcon框架上应用此文件夹结构的位置规则 –

+0

好吧,如果您已经使用php-fpm与您的nginx进行php解释,您可以使用主文档,这是我在第一条评论中提到的。 – M2sh

回答

1

看来你正在使用nginx的Windows内&要使用尔康
所以你然后可以使用主PhalconPHP nginx的配置,其中包括在文档here安装PHP - FastCGI on Windows
这可能是这样的:

server { 
    listen 80; 

    server_name localhost; 

    index index.php index.html index.htm; 

    root C:/nginx/html/tutorial/public; 

    try_files $uri $uri/ @rewrite; 

    location @rewrite { 
     rewrite ^(.*)$ /index.php?_url=$1; 
    } 
    location ~ \.php$ { 
     fastcgi_pass 127.0.0.1:9123; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_split_path_info  ^(.+\.php)(/.+)$; 
     fastcgi_param PATH_INFO  $fastcgi_path_info; 
     fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; 

     include  fastcgi_params; 
    } 


    location ~* ^/(css|img|js|flv|swf|download)/(.+)$ { 
     root C:/nginx/html/tutorial/public; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

尝试了上述的配置。

+0

哇..那是工作..现在我得到异常处理程序的消息,但那是另一回事。只有轻微的变化..因为我的php-cgi.exe配置在127.0.0.1:9000,我不得不改变港口。非常感谢 –