여러가지/구축 & 설치

[실습] Nginx 웹 서버 구축

15June 2024. 2. 3. 18:22

ngnix 웹 서버를 구축하기 위해서 아래의 레파지토리를 사용할 필요는 없다. 내가 그랬을 뿐. 호호.

 

1) 레파지토리 추가

# cd /etc/yum.repos.d/

# vi nginx.repo

-----------------

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

-----------------

2) 설치

# yum install -y nginx

[참고] nginx 설치 안될 때 https://uyijune15.tistory.com/113

 

[ERROR] No package nginx available.

# yum install nginx 와 같이 무엇인가 설치하고자 할 때 발생하는 이슈 Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirror.anigil.com * extras: mirror.anigil.com * updates: mirror.anigil.com N

uyijune15.tistory.com

 

3) 확인

http://[서버 IP]:80

(+) /etc/nginx/conf.d/default.conf 파일에서 포트 변경 가능, default 80

 

 

위의 과정은 일반적인 nginx 웹 서버 구축 과정이다. 참 간단하다.

음... 설정 파일들에 대해서 살짝 살펴보도록하자.

 

일반적으로 nginx는

# cd /etc/nginx

위의 경로에 깔려있을 것이다.

# vi nginx.conf

그중 위의 파일에는 index.html의 파일의 경로와 포트를 지정할 수 있는 부분이 있다.

나의 경우 /usr/share/nginx/html의 index.html 파일로 지정되어있다.

만약 nginx를 깔았는데, 내가 원한 페이지가 출력되지 않는다면 확인해보도록해라.

/var/www/html로 지정되어있으리란 법 없다.