> ## Content Index
> Fetch the complete content index at: https://suitmyself.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# CentOS7 에 Nginx설치
- URL: https://suitmyself.com/nginxseolci/
- Published: 2023-05-29T09:34:48.000Z
- Updated: 2026-09-16T03:10:58.000Z
- Author: Benjamin Kim
- Tags: Server, #Import 2026-09-15 05:58

# CentOS7 에 NginX 설치

---

### 1\. yum 외부 저장소 추가

yum 저장소에 nginx가 없기 때문에 관련 저장소를 추가한다.

```bash
[root@k5w1hcd ~]# cd etc/yum.repos.d/  
[root@k5w1hcd ~ yum.repos.d]# ls CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo CentOS-fasttrack.repo microsoft-prod.repo  
[root@k5w1hcd ~ yum.repos.d]# vi nginx.repo  
[root@k5w1hcd ~ yum.repos.d]#

```

/etc/yum.repos.d/ 경로에 nginx.repo 파일을 추가하고 아래와 같이 작성해준다다.

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

```

위 내용은 공식 사이트에 있으며, OS가 다르다면 해당 OS에 맞게 수정해 주면 된다.

### 2\. yum install

yum install 명령어를 이용해서 설치한다.

```bash
[root@k5w1hcd ~]# yum install -y nginx

```

### 3\. 방화벽 포트 개방

```bash
[root@k5w1hcd ~]#  
[root@k5w1hcd ~]#  
[root@k5w1hcd ~]# firewall-cmd --permanent --zone=public --add-port=8089/tcp  
success  
[root@k5w1hcd ~]# firewall-cmd --reload  
success  
[root@k5w1hcd ~]# firewall-cmd --list-ports  
21/tcp 5000/tcp 5001/tcp 8089/tcp  
[root@k5w1hcd ~]#  

```

### 4\. Nginx 포트 설정

```bash
[root@k5w1hcd ~]# vi /etc/nginx/conf.d/default.conf  

server { 
    listen 8080;  
    server_name localhost;  
    #charset koi8-r;  
    #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;  
    #} 
}

```

### 5\. Nginx 데몬 실행

```bash
[root@k5w1hcd ~]# systemctl start nginx  
[root@k5w1hcd ~]# systemctl enable nginx  
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

```