【发布时间】:2015-02-16 23:45:24
【问题描述】:
我安装 WPN-XM 是为了将 nginx 用于 Laravel 4.2 项目,但只有索引页面可以工作,其他页面如 .../AboutMePage 不能正常工作
我知道 nginx 的 Laravel 配置应该类似于以下 .conf 文件,但我不知道将其准确粘贴到哪里。
# WPN-XM Server Stack
#
# Nginx Server Setup Example
# for an Application based on the Laravel Framework
#
# Do not forget to add an hosts entry for http://laravel.dev
#
server
{
listen 127.0.0.1:80;
root www/laravel/public;
# Make site accessible from http://laravel.dev/
server_name laravel.dev;
index index.php index.html;
location / {
# Request Order: serve request as file, then as directory,
# then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9100;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
【问题讨论】:
-
你说其他页面不工作。错误是什么?对于您的 nginx 配置,请查看 github.com/WPN-XM/WPN-XM/wiki/Files-and-Folders。它写为 'c:\server\bin\nginx\' 作为 nginx 可执行文件的路径,并使用 'c:\server' 作为默认安装位置进行配置
-
我有一个 HTTP 404 错误。我得到了 nginx.conf 文件,但不知道是否应该用上面的代码替换它...:/
-
你的实际配置对 Laravel 来说似乎不错。在 php 位置取消注释 try_files 指令。你不应该需要它。你不能用这个替换 nginx.conf 文件。不要这样做!但是,您可以编辑 nginx.conf(之前制作一个副本)并根据您在此处的配置填充其中的服务器块。你的 nginx.conf 是不是像这里的:github.com/WPN-XM/WPN-XM/blob/master/configs/nginx.conf ?
-
说真的,我不知道你在解释什么,我应该用上面的替换 nginx.conf 文件中的服务器块吗?
-
在您的 nginx.conf 中,您不仅有一个服务器块。你有类似 http { server {} } 的东西。服务器块位于 http 块内。所以编辑 nginx.conf 的第一个 server 块,使它和上面的一样。