aws - nginx 설치

아침7시개발·2022년 4월 28일
0

서버

목록 보기
3/12
  1. Check repo
yum info nginx
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd 2 packages excluded due to repository priority protections Error: No matching Packages to list

yum repository에 nginx가 없어서 에러가 발생한다.

  1. add repo
sudo vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

붙여 넣고 저장한다.

  1. check repo
yum info nginx
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd 
2 packages excluded due to repository priority protections 
Available Packages 
Name        : nginx 
Arch        : x86_64 
Epoch       : 1 
Version     : 1.16.1 
Release     : 1.el7.ngx 
Size        : 766 k 
Repo        : nginx/x86_64 
Summary     : High performance web server 
URL         : http://nginx.org/ 
License     : 2-clause BSD-like license 
Description : nginx [engine x] is an HTTP and reverse proxy server, as well as 
            : a mail proxy server.
  1. install nginx
sudo yum install nginx
  1. version check
nginx -v

nginx 기동

sudo systemctl start nginx

nginx 중지

sudo systemctl stop nginx

nginx 확인

sudo systemctl status nginx
ps -ef | grep nginx

웹서비스 확인

http://hostname:80 or http://hostname

기본 설정 파일

sudo find / -name nginx.conf
/etc/nginx/nginx.conf
sudo vi /etc/nginx/nginx.conf

nginx.conf를 보면 아래의 default.conf 파일은 include 되어있다.

sudo vi /etc/nginx/conf.d/default.conf

확인해보자

server {
    listen       80;
    server_name  localhost;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #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$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

출처

AWS EC2에 NGINX 설치 및 사용하기

profile
쉬엄쉬엄하는 개발자

0개의 댓글