【问题标题】:Nginx configuration for PhalconPHP tutorialPhalconPHP教程的Nginx配置
【发布时间】:2015-10-28 03:11:51
【问题描述】:

我正在尝试使用 PhalconPHP 框架教程设置 ngnix,他们提供了以下结构:

教程/.htaccess

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

tutorial/public/.htaccess

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 的基本配置是:
服务器配置

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规则,但我不知道我错在哪里。

【问题讨论】:

  • 我认为你的 nginx 配置在这里不完整,里面有location 声明吗?只有这两个部分? & 我建议您访问主要文档here
  • 不完整,我刚刚给出了我的根路径。我只是想知道我在 phalcon 框架上应用此文件夹结构的位置规则
  • 好的,如果你使用 php-fpm 和你的 nginx 进行 php 解释,你可以使用我在第一条评论中提到的主文档。
  • 对不起,我想我应该更清楚。

标签: nginx phalcon


【解决方案1】:

您似乎在 nginx 中使用 Windows 并想使用 phalcon
所以你可以安装PHP - FastCGI on Windows 然后使用包含在文档here 中的主要 PhalconPHP nginx 配置。
可能是这样的:

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;
    }
}

试试上面的配置。

【讨论】:

  • 哇.. 工作正常..现在我收到异常处理程序消息,但这是另一回事。只有轻微的变化.. 因为我的 php-cgi.exe 是在 127.0.0.1 上配置的: 9000,我不得不改变端口。非常感谢
猜你喜欢
  • 1970-01-01
  • 2016-08-08
  • 2018-07-02
  • 2023-03-03
  • 1970-01-01
  • 2016-08-20
  • 2022-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多