Mounting two nginx linux system and start nginx deployment and configuration in detail under linux

If you do not see too nginx installation: nginx deployment and configuration in detail under the linux

1, after the first has been installed nginx now install a second nginx

First, enter the directory to compile and install nginx

1. Change directory:

cd /usr/local/src/nginx-1.16.1
Install a second path will be different, I installed here is the third nginx3, if you want to install four to be changed nginx4, need to pay attention nginx.conf no need to change the following command:
./configure \
--prefix=/usr/local/nginx3 \
--sbin-path=/usr/sbin/nginx3 \
--conf-path=/etc/nginx3/nginx.conf \
--error-log-path=/var/log/nginx3/error.log \
--http-log-path=/var/log/nginx3/access.log \
--pid-path=/var/run/nginx3.pid \
--lock-path=/var/run/nginx3.lock \
--http-client-body-temp-path=/var/tmp/nginx3/client \
--http-proxy-temp-path=/var/tmp/nginx3/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx3/fcgi \
--http-uwsgi-temp-path=/var/tmp/nginx3/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx3/scgi \
--user=nginx3 \
--group=nginx3 \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module
View Code

  After the implementation of the following is the path nginx3

2, install the compiler:

make && make install

mkdir -pv /var/tmp/nginx3/client

3, add SysV startup scripts

we /etc/init.d/nginx3

I press enter edit mode, to modify the following two paths to a plurality of Nginx, FIG.

#!/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/nginx3"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx3/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/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
killall -9 nginx
}
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
View Code

 

 

 

4. given the script execution permissions

chmod +x /etc/init.d/nginx3

8. Add nginx server process user

groupadd -r nginx3
useradd -r -g nginx nginx3

9, was added to the list of service management, set up the boot from Kai

chkconfig --add nginx3
chkconfig nginx3 on

 10, nginx.conf modify the port number, here I changed 81

we /etc/nginx3/nginx.conf

 

 11, start nginx3

/ usr / sbin / nginx3 

see the port number
netstat -lntp

 

 

 

 

 11, a start nginx

 

 

 

Guess you like

Origin www.cnblogs.com/weibanggang/p/11487339.html