2017-01-27 2 views
0

내가 금지 오류위치 (별칭) 블록은 내가 <a href="http://my_ip/cachet/" rel="nofollow noreferrer">http://my_ip/cachet/</a>에 액세스 할 때 내가 그것을 말한다 <a href="http://my_ip/cachet/index.php" rel="nofollow noreferrer">http://my_ip/cachet/index.php</a>에 갈 때

location /cachet/ { 
    alias /var/www/cachet/public; 
    try_files $uri $uri/ /index.php?$query_string; 

    location ~ \.php$ { 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     fastcgi_index index.php; 
     include   fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 
} 

을 얻을 금지 부여합니다 "파일을 찾을 수 없습니다."

Nginx에는 cachet 폴더

drwxr-xr-x 13 www-data www-data 4096 jan 27 01:26 cachet 

을 실행 PHP와의 nginx 과정을 읽을 수 있어야 :

[email protected]:/var/www# ps aux -P | grep nginx 
root  21623 0.0 0.0 125756 1684 ?  Ss 01:43 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; 
www-data 21624 0.0 0.0 125756 2300 ?  S 01:43 0:00 nginx: worker process 
www-data 21625 0.0 0.0 125756 2992 ?  S 01:43 0:00 nginx: worker process 
root  21636 0.0 0.0 12888 1120 pts/0 S+ 01:50 0:00 grep --color=auto nginx 
[email protected]:/var/www# ps aux -P | grep php 
root  17562 0.0 0.4 280252 19476 ?  Ss jan26 0:00 php-fpm: master process (/etc/php/7.0/fpm/php-fpm.conf) 
www-data 17563 0.0 0.6 285472 26408 ?  S jan26 0:00 php-fpm: pool www 
www-data 17564 0.0 0.6 285792 26708 ?  S jan26 0:00 php-fpm: pool www 
root  21638 0.0 0.0 12888 1116 pts/0 S+ 01:50 0:00 grep --color=auto php 

답변

0

시도 :

location ^~ /cachet/ { 
    alias /var/www/cachet/public/; 
    if (!-e $request_filename) { rewrite^/cachet/index.php last; } 

    location ~ \.php$ { 
     if (!-f $request_filename) { return 404; } 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     include   fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
    } 
} 
  • 위치 및 별명 값을해야의 양쪽 끝또는 어느 한쪽 끝이 /입니다. 자세한 내용은 this document을 참조하십시오.
  • aliastry_files을 함께 사용하지 마십시오. this long term issuethis caution using if을 참조하십시오.
  • 별칭이 지정된 경로 이름을 얻으려면 $request_filename을 사용하십시오.
0

try_files 지시어의 동작을 잊지 마십시오 : try_files 지침의 마지막 PARAM은 현재 범위 (일반적으로 server)의 모든 location 블록의 재평가로 이어집니다.

/index.php?$query_string;/cachet/과 일치하지 않으므로 PHP 엔진의 중첩 된 위치에 도달하지 못합니다.