【发布时间】:2016-08-19 12:43:24
【问题描述】:
我已经在我的 Windows 机器上安装了 nginx,并且我重新安装了 laravel。我创建了新路线,但除了根工作之外没有其他路线。我收到 404 错误。
错误日志显示
"CreateFile() "C:\nginx/html/myproj/public/register" 失败 (2: 系统找不到指定的文件),客户端:127.0.0.1,服务器: 本地主机,请求:“GET /yacht/public/register HTTP/1.1”,主机: "本地主机""
下面是我的 nginx\conf\nginx.conf 文件。
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
请提出解决此问题的任何想法。
【问题讨论】:
-
解释“除了根目录之外没有其他路由似乎可以工作”的含义会有所帮助。你做了什么;你预期会发生什么;你没想到的究竟发生了什么?这是您必须提供的三件事,我们才能理解问题。
-
编辑了我的帖子。请检查。
-
不幸的是,“它不起作用”和“我做了未知的事情导致了一般性错误”不是缩小范围的有用指标此处可能出现问题的潜在清单。您需要检查您的 nginx 错误日志,并实际找到有关服务器为何返回给定 URI 的 404 not found HTTP 状态代码的更详细的错误信息。否则,提供 可能 可能导致此一般错误的 1001 件事的列表是没有意义的。
-
请添加您的路由文件和无效路由的控制器。
-
我没有使用控制器,我只是在该路由中返回一个视图。
标签: php windows laravel nginx laravel-5.2