nginx上的锂配置

nginx上的锂配置,nginx,lithium,Nginx,Lithium,我想在nginx服务器上部署,但是只有Apache和IIS提供了配置。 在过去,我已经成功地为各种应用程序编写了多个nginx服务器配置,但我正在努力解决这个问题 已经在nginx和Limition论坛上问过这个问题,运气不好 这是迄今为止我所做的最好的 root /var/servers/my_app/app/webroot; location / { index index.php; try_files $uri $uri/ index.php; } location ~

我想在nginx服务器上部署,但是只有Apache和IIS提供了配置。 在过去,我已经成功地为各种应用程序编写了多个nginx服务器配置,但我正在努力解决这个问题

已经在nginx和Limition论坛上问过这个问题,运气不好

这是迄今为止我所做的最好的

root /var/servers/my_app/app/webroot;

location / {
    index index.php;
    try_files $uri $uri/ index.php;
}
location ~ \.php {
            fastcgi_pass unix:/tmp/php.socket;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME /var/servers/my_app/$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_script_name;
    }
问题在于/(根页面)每个链接都预先设置了index.php,例如,而不是

www.example.com/something
我明白了

不确定这是否与nginx配置有关,或者更确切地说,锂离子电池在无法检测到Apache/IIS环境时会这样做。不管怎样,我都解决不了

另一件事是,当我访问“www.example.com/test”(通过直接URL输入)时,页面正确呈现,但“www.example.com/test/”(带尾随斜杠)和“www.example.com/test/anywhere_”被破坏-所有链接都会附加到当前URL,例如,按下相同的链接会创建以下内容:

www.example.com/test/
www.example.com/test/test
www.example.com/test/test/test
编辑:更新配置 (很抱歉编辑延迟了很多时间,但我仍然卡住了,最近重新开始解决此问题)

}

正如我在评论中提到的,现在所有链接都包含index.php,它看起来像:

www.example.com/index.php/something
www.example.com/index.php/stylesheet.css

我认为您的问题是
try\u文件
不应该在
位置
块中

请尝试此处显示的配置:

我帮助定义了它,并一直在本地和生产中使用它。它不应该引起你报告的任何问题

复制如下:

server {
        listen   IP_ADDRESS_HERE:80;
        server_name DOMAIN.COM;

        root   /var/www/DOMAIN.COM/webroot/;
        access_log /var/log/DOMAIN.com/access.log;
        error_log /var/log/DOMAIN.com/error.log warn;

        index  index.php index.html;

        try_files $uri $uri/ /index.php?$args;

        location ~ \.php$
        {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }
        location ~ /\.ht {
                deny all;
        }
}

我认为您的问题是
try\u文件
不应该在
位置
块中

请尝试此处显示的配置:

我帮助定义了它,并一直在本地和生产中使用它。它不应该引起你报告的任何问题

复制如下:

server {
        listen   IP_ADDRESS_HERE:80;
        server_name DOMAIN.COM;

        root   /var/www/DOMAIN.COM/webroot/;
        access_log /var/log/DOMAIN.com/access.log;
        error_log /var/log/DOMAIN.com/error.log warn;

        index  index.php index.html;

        try_files $uri $uri/ /index.php?$args;

        location ~ \.php$
        {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include /etc/nginx/fastcgi_params;
        }
        location ~ /\.ht {
                deny all;
        }
}

正如我所怀疑的,问题在于Lili依赖于一些环境变量,在本例中,链接生成,它使用PHP_SELF,这恰好是不正确的

解决方案:

fastcgi_param PATH_INFO $fastcgi_path_info;
与之前的错误相反:

fastcgi_param PATH_INFO $fastcgi_script_name;
因此,最终配置:

root /var/server/my_app/app/webroot/;

index index.php index.html;
try_files $uri $uri/ /index.php?$args;

location ~ \.php {
        fastcgi_pass unix:/tmp/php.socket;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/servers/my_app$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~/\.ht {
        deny all;
}

多亏了rmarscher和mehlah@lithum论坛。

因为我怀疑问题在于Lili依赖于一些环境变量,在本例中是链接生成,它使用PHP_SELF,这恰好是错误的

解决方案:

fastcgi_param PATH_INFO $fastcgi_path_info;
与之前的错误相反:

fastcgi_param PATH_INFO $fastcgi_script_name;
因此,最终配置:

root /var/server/my_app/app/webroot/;

index index.php index.html;
try_files $uri $uri/ /index.php?$args;

location ~ \.php {
        fastcgi_pass unix:/tmp/php.socket;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/servers/my_app$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
}

location ~/\.ht {
        deny all;
}

感谢rmarscher和mehlah@lithum论坛。

谢谢你,真不敢相信我所有的搜索都没有返回那篇维基文章。但是问题仍然存在,现在在每个页面(甚至是/test)中,“index.php”都被链接到了。谢谢你,不能相信我所有的搜索都没有返回那篇维基文章。但是问题仍然存在,现在在每个页面(甚至是/test)中,“index.php”都被垂直链接。@就连我也有同样的问题。我按照Nginx的Limition wiki上的说明进行操作,但效果不佳。是我的question@even我也有同样的问题。我按照Nginx的Limition wiki上的说明进行操作,但效果不佳。这是我的问题