nginx 가상 호스트 구축
[root@web-nginx ~]# cat /etc/redhat-release 시스템 버 전 번호 보기 CentOS release 6.6 (Final) [root@web-nginx ~]# uname -r //print the kernel release 2.6.32-504.el6.x86_64 [root@web-nginx ~]# uname -m // print the machine hardware name x86_64 [root@web-nginx ~]# rpm -qa gcc gcc-c++ gcc-4.4.7-11.el6.x86_64 gcc-c++-4.4.7-11.el6.x86_64[root@web-nginx ~]# rpm -qa pcre pcre-devel pcre-7.8-6.el6.x86_64 [root@web-nginx ~]# yum -y install pcre pcre-devel pcre 라 이브 러 리 설치 (정규 표현 식 호 환) [root@web-nginx ~]# rpm -qa openssl openssl-devel openssl-1.0.1e-30.el6.x86_64 [root@web-nginx ~]# yum -y install openssl openssl-devel (안전 한 SSL 프로 토 콜 전송 http) [root@web-nginx ~]# rpm -qa pcre pcre-devel openssl openssl-devel pcre-7.8-6.el6.x86_64 openssl-1.0.1e-30.el6.11.x86_64 openssl-devel-1.0.1e-30.el6.11.x86_64 pcre-devel-7.8-6.el6.x86_64 [root@web-nginx nginx-1.6.3]# wget http://nginx.org/download/nginx-1.6.3.tar.gz 설치 팩 다운로드 [root@web-nginx nginx-1.6.3]# ls 패키지 다운로드 성공 확인 [root@web-nginx nginx-1.6.3]# tar -zxvf nginx-1.6.3.tar.gz 스트레스 해소 [root@web-nginx nginx-1.6.3]# ls 압축 해제 결과 보기 [root@web-nginx nginx-1.6.3]# cd nginx-1.6.3[root@web-nginx nginx-1.6.3]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module 사용자 정의 설치 설정 [root@web-nginx nginx-1.6.3]# make && make install 컴 파일 설치 [root@web-nginx nginx-1.6.3]# echo $? 실행 결과 보기 0 성공root@web-nginx nginx-1.6.3]# useradd nginx -s /sbin/nologin -M 사용자 만 들 기 [root@web-nginx nginx-1.6.3]# id nginx 사용자 와 그룹 정보 보기 uid = 500 (nginx) gid=500(nginx) groups=500(nginx)[root@web-nginx nginx-1.6.3]# ll /application/nginx-1.6.3/ total 16 drwxr-xr-x. 2 root root 4096 Jul 5 15:43 conf 파일 디 렉 터 리 설정 drwxr-xr-x. 2 root root 4096 Jul 5 15:43 html 사이트 디 렉 터 리 drwxr-xr-x. 2 root root 4096 Jul 5 15:43 logs 로그 파일 디 렉 터 리 drwxr-xr-x. 2 root root 4096 Jul 5 15:43 sbin 실행 파일 디 렉 터 리 [root@web-nginx nginx-1.6.3]# ln -s /application/nginx-1.6.3/ /application/nginx 편리 하 게 사용 하기 위해 소프트 링크 를 만들다. [root@web-nginx nginx-1.6.3]# ll /application/ total 4 lrwxrwxrwx. 1 root root 25 Jul 5 15:53 nginx -> /application/nginx-1.6.3/ drwxr-xr-x. 6 root root 4096 Jul 5 15:43 nginx-1.6.3[root@web-nginx nginx-1.6.3]# /application/nginx/sbin/nginx 서비스 시작 [root@web-nginx nginx-1.6.3]# ps -ef |grep nginx |grep -v grep 서비스 프로 세 스 보기 root 4762 1 0 15:55 ? 00:00:00 nginx: master process /application/nginx/sbin/nginx 주 프로 세 스 nginx 4763 4762 0 15:55 ? 00:00:00 nginx: worker process 작업 프로 세 스 [root@web-nginx nginx-1.6.3]# netstat -lntup |grep nginx 포트 는 80tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN [root@web-nginx nginx-1.6.3]# curl 127.0.0.1 로 컬 브 라 우 저 로그 인 테스트 에 성공 하 였 습 니 다.
Nginx 가상 호스트 설정:
가상 호스트: [root@web-nginx ~]# cd /application/nginx/conf[root@web-nginx conf]# cp nginx.conf /data/root/backup/ nginx. conf 프로필 백업 [root@web-nginx conf]# egrep -v "#|^$" nginx.conf.default>nginx.conf nginx. conf. default 에 주석 이 없고 빈 줄 이 아 닌 내용 을 nginx. conf [로 내 보 냅 니 다.root@web-nginx conf]# mkdir ../html/www [root@web-nginx conf]# mkdir ../html/bbs [root@web-nginx conf]# mkdir ../html/blog [root@web-nginx conf]# echo "www.etiantian.org" >../html/www/index.html [root@web-nginx conf]# echo "bbs.etiantian.org" >../html/bbs/index.html [root@web-nginx conf]# echo "blog.etiantian.org" >../html/blog/index.html[root@web-nginx conf]# cat ../html/{www,bbs,blog}/index.html www.etiantian.org bbs.etiantian.org blog.etiantian.org[root@web-nginx conf]# vim nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etiantian.org alias etiantian.org;
access_log /app/logs/www_logs/access_www.log main;
location / {
root html/www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name bbs.etiantian.org;
access_log /app/logs/bbs_logs/access_bbs.log main;
location / {
root html/bbs;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name blog.etiantian.org;
access_log /app/logs/blog_logs/access_blog.log main;
location / {
root html/blog;
index index.html index.htm;
}
[root@web-nginx conf]# vim /etc/hosts192.168.10.104 www.etiantian.org etiantian.org 192.168.10.104 bbs.etiantian.org blog.etiantian.org[root@web-nginx conf]# /application/nginx/sbin/nginx -t nginx: the configuration file /application/nginx-1.6.3/conf/nginx.conf syntax is ok nginx: configuration file /application/nginx-1.6.3/conf/nginx.conf test is successful [root@web-nginx conf]# /application/nginx/sbin/nginx -s reload [root@web-nginx conf]# curl blog.etiantian.org blog.etiantian.org [root@web-nginx conf]# curl www.etiantian.org www.etiantian.org [root@web-nginx conf]# curl bbs.etiantian.org bbs.etiantian.org [root@web-nginx conf]# curl etiantian.org www.etiantian.org [root@web-nginx conf]# ll /app/logs/bbs_logs/ total 4 -rw-r--r--. 1 root root 183 Jul 5 20:50 access_bbs.log [root@web-nginx conf]# ll /app/logs/blog_logs/ total 4 -rw-r--r--. 1 root root 183 Jul 5 20:50 access_logs.log[root@web-nginx conf]# ll /app/logs/www_logs/ total 4 -rw-r--r--. 1 root root 366 Jul 5 20:56 access_www.log
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.