首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PhalconPHP教程的Nginx配置

PhalconPHP教程的Nginx配置
EN

Stack Overflow用户
提问于 2015-10-28 03:11:51
回答 1查看 1.7K关注 0票数 1

我正在尝试用PhalconPHP框架教程来设置ngnix,它们提供了如下结构:

tutorial/.htaccess

代码语言:javascript
复制
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

tutorial/public/.htaccess

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

另一个文件夹是app,它包含文件夹:controllersmodelsviews。现在,本教程在apache上运行得很好,但是在nginx上,我尝试了不同的规则,这些规则不起作用。我的ngnix的基本配置是:

服务器配置

代码语言:javascript
复制
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上设置本教程的位置规则吗?我甚至在网上把.htaccess规则转换成nginx规则,但我不知道我错了什么地方。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-28 08:15:09

似乎您在nginx中使用Windows &想要使用phalcon

因此,您可以安装PHP - FastCGI on Windows,然后使用docs 这里中包含的主PhalconPHP nginx。

可能是这样的:

代码语言:javascript
复制
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;
    }
}

尝试上面的配置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33382268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档