-
Nginx 설치하기 for Centos7Web/Nginx 2020. 9. 23. 10:39SMALL
웹 서버 구축을 위한 오픈소스 소프트웨어로 유명한 두 가지가 있다.
Apache, Nginx가 그것이다.
2000년대 초, 중반까지만 해도 Apache가 웹 서버의 대부분을 차지했지만
2010년대 중 후반 현재에 이르러서는 Nginx의 점유율도 점차 높아지고 있다.
Nginx는 Apache에 비해 서버에 부담이 적다는 이유로 사용량이 증가하는 추세이다.
이번 포스팅에서는 레드햇 계열인 Centos에 Nginx를 설치하는 방법을 적어보려 한다.
Originally from http://nginx.net/ 1. epel 저장소 확인 및 설치하기
$ yum repolist | grep epel * epel: d2lzkl7pfhq30w.cloudfront.net !epel/x86_64 Extra Packages for Enterprise Linux 13,445+1 // if doesn't exist $ yum install epel-release
2. Nginx 설치하기
// 설치 $ yum install -y nginx // 버전 확인 $ nginx -v nginx version: nginx/1.18.0
3. 설정파일 확인하기
$ vi /etc/nginx/nginx.conf ... server { listen 80 default_server; // 기본 리슨 포트 번호: 80 listen [::]:80 default_server; server_name _; // 서버 도메인 주소 및 IP 주소 root /usr/share/nginx/html; // nginx 관련 root 디렉토리 }
자세한 파일 설정은 nginx.org/en/docs/beginners_guide.html 여기서 참고 가능
4. Nginx 데몬 시작
// 데몬 시작 $ systemctl start nginx // 이후 데몬 실행 가능 설정 $ systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service // nginx 데몬 상태 확인하기 $ systemctl status nginx ● nginx.service - nginx - high performance web server Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2020-09-21 13:42:27 KST; 2h 13min ago Docs: http://nginx.org/en/docs/ Process: 2372 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS) Process: 2375 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 2376 (nginx) CGroup: /system.slice/nginx.service ├─2376 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf └─2377 nginx: worker process Sep 21 13:42:27 lifestyleredesign systemd[1]: Stopped nginx - high performance web server. Sep 21 13:42:27 lifestyleredesign systemd[1]: Starting nginx - high performance web server... Sep 21 13:42:27 lifestyleredesign systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) af...ory Sep 21 13:42:27 lifestyleredesign systemd[1]: Started nginx - high performance web server. Hint: Some lines were ellipsized, use -l to show in full.
5. Nginx 실행 포트, 프로세스, 로그 위치 확인
// 포트 확인 $ netstat -natp | grep nginx tcp 0 0.0.0.0:80 0.0.0.0"* LISTEN 4556/nginx: master // 프로세스 확인 $ ps -ef | grep nginx root 4556 1 0 15:54 ? 00:00:00 nginx: master process /usr/sbin/nginx nginx 4557 4556 0 15:43 ? 00:00:00 nginx: worker process root 4581 4069 0 15:44 pts/0 00:00:00 grep --color=auto nginx // log 위치 확인 $ cd /var/log/nginx $ ls access.log error.log
centos는 yum이라는 패키지 도구가 있어 비교적 편리하게 설치할 수 있다.
nginx의 기본 설정들(포트, 프로세스, root 디렉토리 등)을 숙지하고 있는다면
이후 진행되는 개발에 있어 더욱 편리할 수 있으니
꼭 직접 설치해보고 마주하는 에러들에 대해서 해결해보는 것을 추천한다.
LIST'Web > Nginx' 카테고리의 다른 글
Nginx에 MySQL 설치하기 for Centos7 (0) 2020.10.06 Nginx에 Node.js 설치하기 ( fast-cgi ) for Centos7 (0) 2020.10.05 Nginx에 php-fpm 설치하기 for Centos7 (0) 2020.09.29 댓글