본문으로 바로가기

CENTOS 7, NGINX 환경 설정

category 컴퓨터/리눅스 2017. 8. 23. 21:54
CENTOS 7, NGINX  환경 설정


nginx 실행
 ]# systemctl restart nginx

 .시스템 재시작시 자동으로 실행
 ]# systemctl enable nginx.service
  버젼확인
  ]# nginx -v
   nginx version: nginx/1.12.1
   
5.nginx 환경설정
  ]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf_org
  ]# vi /etc/nginx/conf.d/default.conf

server {
    listen       8080;
    #server_name  localhost;
    server_name  sajuplus.net www.sajuplus.net;

    # root   /home/myhome/ones;
    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        try_files $uri $uri/ =404;
    }

    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   /usr/share/nginx/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$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        include fastcgi_params;
    }

    # deny access to .htaccess files, if Apaches document root
    # concurs with nginxs one
    #
    #location ~ /.ht {
    #    deny  all;
    #}
}

위 설정이 완료되었다면,  Nginx 서버 재시작
 ]# systemctl restart nginx
 
 http://192.168.1.12:8080/