1

yii2 기본 응용 프로그램에 대한 nginx 서버 구성에 문제가 있습니다. 다른 폴더 "another_folder"에있는다른 폴더에 Nginx Yii2 구성

server { 
    listen  80 ; 

    access_log /var/log/nginx/access-server.log; 
    error_log /var/log/nginx/error-server.log; 

    charset utf-8; 

    location /fetch { 
      root /usr/share/nginx/html/another_folder/web/; 
      try_files $uri $uri/ /index.php$is_args$args; 
    } 

     location ~ \.php$ { 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass 127.0.0.1:9000; 
      fastcgi_index index.php; 
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
      include  fastcgi_params; 
     } 

} 

내 프로젝트 :

여기 내 서비스 블록 파일입니다. 그리고 나는 사용자가 url에 갈 때 : http://ip/fetch 파일 nginx는 다른 폴더의 파일을 제공합니다. 지정되지 입력 파일을 :

2017/02/11 12:38:52 [error] 4242#0: *12 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/html/index.php (No such file or directory)" while reading response header from upstream 

을 그리고 동생을 보여줍니다

내 오류 로그 파일은 저를 반환하지 않습니다.

이 문제와 관련하여 도움을 주시겠습니까?

감사합니다.

+0

'/ usr/share/nginx/html/another_folder/web/index.php' 또는'/ usr/share/nginx/html/another_folder/web '에 /fetch/index.php를 넣으시겠습니까?/fetch/index.php'? –

+0

이 폴더에 /usr/share/nginx/html/another_folder/web/index.php – Farkhad

+1

'alias' 지시어를 사용해야합니다. [이 답변] (http://stackoverflow.com/questions/42137658/nginx-forwarding-few-localhosts-to-php-fpm/42138410#42138410)을 참조하십시오. –

답변

1

덧글에 덧붙여, 별칭이 지정된 경로 내의 정적 파일과 일치하지 않는 /fetch으로 시작하는 URI는 모두 /fetch/index.php으로 리디렉션되어야합니다.

location ^~ /fetch { 
    alias /usr/share/nginx/html/another_folder/web; 

    if (!-e $request_filename) { rewrite^/fetch/index.php last; } 

    location ~ \.php$ { 
     if (!-f $request_filename) { return 404; } 

     include  fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
     fastcgi_pass 127.0.0.1:9000; 
    } 
} 

우리는 alias 때문에 this long term issuetry_files을 사용하지 마십시오.

if에 대해서는 this caution을 참조하십시오.