테스트 사이트 - 개발 중인 베타 버전입니다

NginX 설정 질문좀 드릴께요. default 파일

불드래곤 8년 전 조회 3,707

안녕하세요. 초보입니다. 그누보드 설치 준비중에 LEMP를 구성하고 있습니다.



default 파일에 있는 서버블락 설정인데요 여기저기참고하다 보니 아래처럼 되었어요. 잘 동작중입니다.


location ~ \.php$ {

#try_files $uri =404;

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/run/php/php7.0-fpm.sock;

#fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}


근데 궁금한게 주석처리한 저 두 줄을 넣으면 신택스 에러가 나오더라고요


snippets/fastcgi-php.conf; 를 임포트하면서 중복된다고요.


그래서 snippets/fastcgi-php.conf; 의 파일을 봤는데 


아래쪽거 fastcgi_index index.php; 이거는 완전히 같은반면


 위에있는

#try_files $uri =404; 

이거는 

try_files $fastcgi_script_name =404; 

이렇게 되어있더라고요. 


이거 이렇게 다른데 상관 없을 까요?




아래는  snippets/fastcgi-php.conf; 파일의 내용입니다.



# regex to split $uri to $fastcgi_script_name and $fastcgi_path

fastcgi_split_path_info ^(.+\.php)(/.+)$;


# Check that the PHP script exists before passing it

try_files $fastcgi_script_name =404;


# Bypass the fact that try_files resets $fastcgi_path_info

# see: http://trac.nginx.org/nginx/ticket/321">http://trac.nginx.org/nginx/ticket/321

set $path_info $fastcgi_path_info;

fastcgi_param PATH_INFO $path_info;


fastcgi_index index.php;

include fastcgi.conf;






댓글을 작성하려면 로그인이 필요합니다.

답변 1개

제가 사용하는 서버의 환경파일입니다. 참고하세요.

</p>

<p style="font-size:11pt; font-family:맑은 고딕;">server {

    listen       80;

    server_name  www.mydomain.com;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">    charset utf-8;

    access_log  /var/log/nginx/www.mydomain.com.access.log  main;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">    root   /usr/share/nginx/html;</p>

<p style="font-size:11pt; font-family:맑은 고딕;"> </p>

<p style="font-size:11pt; font-family:맑은 고딕;">    location / {

        index  index.php index.html index.htm;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        try_files $uri $uri/ /index.php?$args;

    }</p>

<p style="font-size:11pt; font-family:맑은 고딕;"> </p>

<p style="font-size:11pt; font-family:맑은 고딕;">    error_page  404              /404.html;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">    # redirect server error pages to the static page /50x.html

    #

    error_page   500 502 503 504  /50x.html;

    location = /50x.html {

        root   /usr/share/nginx/html;

    }</p>

<p style="font-size:11pt; font-family:맑은 고딕;">    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ \.php$ {

        root           /usr/share/nginx/html;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        try_files $uri =404;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_param  SCRIPT_NAME $fastcgi_script_name;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_buffer_size 128k;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_buffers 256 16k;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_busy_buffers_size 256k;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        fastcgi_temp_file_write_size 256k;</p>

<p style="font-size:11pt; font-family:맑은 고딕;">        include        fastcgi_params;

    }</p>

<p style="font-size:11pt; font-family:맑은 고딕;">    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    location ~ /\.ht {

        deny  all;

    }

}</p>

<p style="font-size:11pt; font-family:맑은 고딕;">

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인