phalcon nginx的配置问题

用Docker搭建phalcon的运行环境,出现点小问题, 不知道是什么情况

用phalcon官方提供的nginx配置,rewrite规则不生效, 以及网上查了很多资料,都没有用...

css, js等资源加载不正常..会出现一个奇怪的index.php

图片描述

这种事什么鬼情况,怎么改好像都没用.

配置是这样的:

server {
    listen   80;
    index index.php index.html index.htm;
    server_name www.aaa.com aaa.com;

    root /data/www/aaa/public;

    try_files $uri $uri/ @rewrite;
    location @rewrite {
        rewrite ^(.+)$ /index.php?_url=$1 last;
    }

    location ~ \.php(.*)$ {
        include fastcgi_params;
        fastcgi_pass   php-fpm:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /data/www/aaa/public/$fastcgi_script_name;
        fastcgi_param  APPLICATION_NAME zphal;
    }

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

可以正常使用的Apache规则是这样的:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule  ^$ public/    [L]
    RewriteRule  (.*) public/$1 [L]
</IfModule>
阅读 5.6k
2 个回答

这个问题解决了..

是程序本身的URI设置和nginx的起了冲突;

之前设置的:

'baseUri'        => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]), 

改成URI

  'baseUri'        => '/',

就可以了(不过需要配置host或者域名);

因为我nginx的documentroot解析到了public下.

这个应该是你在生成URL的时候不正确吧。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题