2016-08-19 3 views
-1

Windows 컴퓨터에 nginx를 설치했으며 laravel을 새로 설치했습니다. 새로운 루트를 만들었지 만 루트 작업을 제외한 다른 루트는 만들지 않았습니다. 404 오류가 발생합니다.Nginx Windows Laravel 경로가 작동하지 않습니다.

오류 로그는

"를 CreateFile()"C 말한다 : \의 nginx/HTML /의 Myproj /는 "(2 다음 지정한 파일을 찾을 수 없습니다) 실패 등록/공개, 클라이언트 : 127.0. 0.1 서버 : localhost를 요청 : "GET/요트/공공/HTTP 등록/1.1", 호스트 : "localhost"를 "

아래는 내의 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; 
# } 
#} 

} 

해결 방법은 무엇입니까?

+0

"루트 이외의 다른 경로는 작동하지 않는 것 같습니다 _"은 도움이된다는 것을 의미합니다. 뭐 했어; 너는 무엇을 기대 했는가? 실제로 당신이 예상하지 못한 것은 무엇입니까? 이것들은 당신이 우리가 문제를 이해할 수 있도록 제공해야만하는 세 가지입니다. – Sherif

+0

내 게시물을 편집했습니다. Pls 수표. –

+0

불행히도 "_it did not work_"및 "_I unknown unknown thing in generic error_"는 여기에 잘못되었을 가능성이있는 항목의 범위를 좁히는 데 유용한 지표는 아닙니다. nginx 오류 로그를 확인하고 실제로 서버가 404 URI를 찾을 수없는 HTTP 상태 코드를 반환하는 이유에 대한 자세한 오류 정보를 찾으십시오. 그렇지 않으면,이 일반적인 오류를 초래할 가능성이있는 1001 가지 목록을 제공하는 것은 의미가 없습니다. – Sherif

답변

1

nginx 구성에서 root는 Laravel 공용 폴더를 가리켜 야합니다. 즉

server { 
    listen 80 default_server; 

    root /var/www/laravel/public/; 
    index index.php index.html index.htm; 

    location/{ 
     try_files $uri $uri/ /index.php$is_args$args; 
    } 

    # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock 
    location ~ \.php$ { 
      try_files $uri /index.php =404; 
      fastcgi_pass unix:/var/run/php5-fpm.sock; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include fastcgi_params; 
    } 

}

3

문제는 내가 그것의 nginx를 사용하는 대신 현지에

php artisan serve 

를 사용하는 것이 좋습니다 생각 때문에

C:\nginx/html/myproj/public/register 

의 슬래시와 백 슬래시의 수 .

+0

안녕하세요. 감사합니다. 이것은 효과가 있었다 !! 이 문제를 피하기 위해 nginx를 구성 할 수있는 방법이 있습니까? –

+0

이 문제를 해결하려면 nginx 구성 파일을 편집해야한다고 생각합니다. –

관련 문제