nginx代理服务器的简单实现
	我们要创建一个nginx服务器,代理ip为192.168.0.101,本机作为测试主,本机的ip是192.168.0.234
	 
	 
	Nginx代理服务器的配置
	首先,配置好yum源
	[root@server70 ~]# yum groupinstall -y "Development Tools" "Development Libraries"
	[root@server70 ~]# yum install gcc openssl-devel pcre-devel zlib-devel –y
	Lftp 192.168.0.254
	下载nagios-3.2.1.tar.gz
	Tar xf nginx-1.1.3.tar.gz
	# groupadd nginx
	# useradd -g nginx -s /bin/false -M nginx
	#cd nginx-1.1.3
	./configure\
	 --prefix=/usr \
	 --sbin-path=/usr/sbin/nginx \
	 --conf-path=/etc/nginx/nginx.conf \
	 --error-log-path=/var/log/nginx/error.log \
	 --http-log-path=/var/log/nginx/access.log \
	 --pid-path=/var/run/nginx/nginx.pid \
	 --lock-path=/var/lock/nginx.lock \
	 --user=nginx \
	 --group=nginx \
	 --with-http_ssl_module \
	 --with-http_flv_module \
	 --with-http_stub_status_module \
	 --with-http_gzip_static_module \
	 --http-client-body-temp-path=/var/tmp/nginx/client/ \
	 --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
	 --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
	 --with-pcre
	 
	 Make && make install
	 
	 Vim /etc/init.d/nginx
	#!/bin/sh
	#
	# nginx - 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
	# config:      /etc/sysconfig/nginx
	# pidfile:     /var/run/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/sbin/nginx"
	prog=$(basename $nginx)
	 
	NGINX_CONF_FILE="/etc/nginx/nginx.conf"
	 
	[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
	 
	lockfile=/var/lock/subsys/nginx
	 
	make_dirs() {
	   # make required directories
	   user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
	   options=`$nginx -V 2>&1 | grep 'configure arguments:'`
	  for opt in $options; do
	       if [ `echo $opt | grep '.*-temp-path'` ]; then
	           value=`echo $opt | cut -d "=" -f 2`
	           if [ ! -d "$value" ]; then
	               # echo "creating" $value
	               mkdir -p $value && chown -R $user $value
	           fi
	       fi
	   done
	}
	 
	start() {
	    [ -x $nginx ] || exit 5
	    [ -f $NGINX_CONF_FILE ] || exit 6
	    make_dirs
	    echo -n $"Starting $prog: "
	    daemon $nginx -c $NGINX_CONF_FILE
	    retval=$?
	    echo
	    [ $retval -eq 
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>







