리눅스 서버에서 Nginx 기본 설치 및 설정 방법
Nginx는 가볍고 빠른 웹 서버로 많이 사용됩니다. 이번 글에서는 리눅스 서버에서 Nginx를 설치하고 기본 설정하는 방법을 안내합니다.
1. Nginx 설치
RockyLinux, CentOS, Fedora 등에서는 아래 명령어로 설치할 수 있습니다.
sudo dnf install nginx -y
Ubuntu/Debian 계열에서는:
sudo apt update
sudo apt install nginx -y
2. 서비스 시작 및 부팅 시 자동 실행
sudo systemctl start nginx
sudo systemctl enable nginx
3. 방화벽 설정
HTTP(80), HTTPS(443) 포트를 엽니다.
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
4. 기본 설정 파일 위치
- 메인 설정:
/etc/nginx/nginx.conf
- 사이트별 설정:
/etc/nginx/conf.d/
5. 설정 테스트 및 재시작
설정 변경 후 아래 명령어로 오류를 확인하고 서비스를 재시작합니다.
sudo nginx -t
sudo systemctl restart nginx
Nginx를 설치하고 기본 설정을 마치면 웹 서비스를 빠르고 안정적으로 운영할 수 있습니다!
댓글남기기