본문 바로가기
카테고리 없음

centos7과 nginx에서 정적 파일 제공

by DogBull 2015. 5. 31.

아래와 같이 nginx가 설정되어 있다.

server {

        listen       80 default_server;

        server_name  localhost;


        location / {

                proxy_pass http://localhost:8000;

        }


        location /static {

                alias /home/jhpark/sites/www.jrr.kr/static;

        }


        error_page  404              /404.html;

        location = /40x.html {

        

        }


        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

        

        }

}


이 경우, static 파일 제공 디렉토리(/home/jhpark/sites/www.jrr.kr/static)부터 부터 최상위 디렉토리(/) 까지 모두 실행 권한이 있어야 한다.

drwxr-xr-x root   root   /

drwxr-xr-x root   root   home

drwx--x--x jhpark jhpark jhpark

drwxr-xr-x jhpark jhpark sites

drwxr-xr-x jhpark jhpark www.jrr.kr

drwxr-xr-x jhpark jhpark static


이와는 별도로 selinux가 활성화 되어 있을 경우 (getenforce 명령의 결과 Enforcing가 출력될 경우)

sudo chcon -Rt httpd_sys_content_t /home/jhpark/sites/www.jrr.kr/static

을 해주어야 함.