nginx 가상 호스트 설치
4357 단어 local
nginx 의존 라 이브 러 리 설치
[root@localhost src]# yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.4.4.tar.gz
[root@localhost src]# tar zxvf nginx-1.4.4.tar.gz
[root@localhost src]# cd nginx-1.4.4
[root@localhost nginx-1.4.4]# ./configure -- help 보기 옵션 으로 설치 할 수도 있 습 니 다.
[root@localhost nginx-1.4.4]# make
[root@localhost nginx-1.4.4]# make install
설치 완료 후 시작 nginx
[root@localhost ~]# /usr/local/nginx/sbin/nginx
스 크 립 트 시작 정지 ngix 설정
아래 셸 스 크 립 트 내용 은 Nginx 의 실제 컴 파일 에 따라 설 치 된 설정 을 수정 해 야 합 니 다.
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
화해시키다 lockfile=/var/lock/nginx.lock
nginx="/usr/sbin/nginx"
vim /etc/init.d/nginx
#! /bin/bash
#nx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
#
# processname: nginx
# config: /etc/nginx/nginx.conf
# pidfile: /var/run/nginx/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/local/nginx/sbin/nginx" // 나의 nginx 경로
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" // 나의 nginx 경로
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx // 나의 nginx 경로
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
-------------------------------------------------------------------------------
[root@localhost ~]# chmod +x /etc/init.d/nginx
[root@localhost ~]# chkconfig --add nginx
[root@localhost ~]# chkconfig nginx on
[root@localhost ~]# chkconfig --list | grep nginx
nginx 0: 닫 기 1: 닫 기 2: 사용 하기 3: 사용 하기 4: 사용 하기 5: 사용 하기 6: 닫 기
nginx 가상 호스트 설정
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
server { listen 80; server_name 123.com;
접근 기기 의 hosts 파일 에 도 메 인 이름 을 설정 합 니 다. 그리고 123. com 을 방문 하 세 요.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
DEEP DIVE 한 장 요약 (스코프)변수는 코드의 가장 바깥 영역뿐 아니라 코드 블록이나 함수 몸체 내에서도 선언할 수 있다. 모든 식별자(변수 이름, 함수 이름, 클래스 이름 등)는 자신이 선언된 위치에 의해 다른 코드가 식별자 자신을 참조할 수 있...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.