龙空技术网

nginx(多实例)安装部署操作参考(linux)

运维Danrtsey 338

前言:

当前看官们对“nginxcgibin”大约比较关切,大家都想要剖析一些“nginxcgibin”的相关资讯。那么小编也在网络上搜集了一些有关“nginxcgibin””的相关文章,希望姐妹们能喜欢,大家一起来学习一下吧!

单nginx安装参考

里面涉及内容基本与原来发表的文章相同,这里仅列举第二个nginx的安装与启动配置

1. 部署规划

实例1安装规划

软件安装路径:/usr/local/nginx/

软件日志路径:/usr/local/nginx/logs/

软件二进制路径:/usr/local/nginx/sbin/

软件缓存代理等路径:/usr/local/nginx/{client_body,proxy,fastcgi,uwsgi,scgi}

软件主配置文件路径:/usr/local/nginx/conf

软件子配置文件路径:/usr/local/nginx/conf/conf.d/

Pidfile路径:/usr/local/nginx/logs/nginx.pid

Lockfile路径:/var/lock/nginx.lock

sbin-path路径:/usr/local/nginx/sbin/nginx

端口规划:80

实例2安装规划

软件安装路径:/usr/local/nginx2/

软件日志路径:/usr/local/nginx2/logs/

软件二进制路径:/usr/local/nginx2/sbin/

软件缓存代理等路径:/usr/local/nginx2/{client_body,proxy,fastcgi,uwsgi,scgi}

软件主配置文件路径:/usr/local/nginx2/conf

软件子配置文件路径:/usr/local/nginx2/conf/conf.d/

Pidfile路径:/usr/local/nginx2/logs/nginx2.pid

Lockfile路径:/var/lock/nginx2.lock

sbin-path路径:/usr/local/nginx2/sbin/nginx2

端口规划 :8080

2 Nginx2安装

l 添加用户与用户组(用户名请自行定义)

groupadd -r nginx2 && useradd -s /sbin/nologin -r -g nginx2 nginx2

l Nginx2部署环境准备

mkdir -pv /usr/local/nginx2/{logs,client_body,proxy,fastcgi,uwsgi,scgi}chown -R nginx2:nginx2 /usr/local/nginx2

l Nginx2安装

cd /opt/nginx-1.19.1./configure \--prefix=/usr/local/nginx2 \--pid-path=/usr/local/nginx2/logs/nginx2.pid  \--sbin-path=/usr/local/nginx2/sbin/nginx2 \--conf-path=/usr/local/nginx2/conf/nginx.conf \--error-log-path=/usr/local/nginx2/logs/error.log \--http-log-path=/usr/local/nginx2/logs/access.log \--lock-path=/var/run/nginx2.lock \--user=nginx2 \--group=nginx2 \--with-http_ssl_module \--with-http_v2_module \--with-http_dav_module \--with-http_flv_module \--with-http_realip_module \--with-http_addition_module \--with-http_xslt_module \--with-http_stub_status_module \--with-http_sub_module \--with-http_random_index_module \--with-http_degradation_module \--with-http_secure_link_module \--with-http_gzip_static_module \--with-http_perl_module \--with-pcre=../pcre-8.44 \--with-zlib=../zlib-1.2.11 \--with-openssl=../openssl-1.1.1g \--with-debug \--with-file-aio \--with-mail \--with-mail_ssl_module \--http-client-body-temp-path=/usr/local/nginx2/client_body \--http-proxy-temp-path=/usr/local/nginx2/proxy \--http-fastcgi-temp-path=/usr/local/nginx2/fastcgi \--http-uwsgi-temp-path=/usr/local/nginx2/uwsgi \--http-scgi-temp-path=/usr/local/nginx2/scgi \--with-stream \--with-ld-opt="-Wl,-E"make && make installcd /usr/local/nginx2/conf
3. 配置nginx2系统服务

1、添加nginx系统服务启动脚本

vi /etc/init.d/nginx2#!/bin/bash## nginx - this script starts and stops the nginx daemon## chkconfig:   2345 88 12# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \#               proxy and IMAP/POP3 proxy server## processname: nginx# config:      /usr/local/nginx2/conf/nginx.conf# pidfile:     /usr/local/nginx2/logs/nginx2.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/nginx2/sbin/nginx2"prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx2/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/nginx2.lock 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} 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)        $1        ;;    status)        rh_status        ;;    *)        echo $"Usage: $0 {start|stop|status|restart}"        exit 2        ;;esac

2、配置nginx2系统服务及自启动

chmod +x /etc/init.d/nginx2chkconfig --add nginx2 && chkconfig nginx2 onchkconfig --list nginx2

3、启动与停止nginx服务(启动时注意端口不可冲突)

service nginx2 start    或使用  systemctl start nginx2service nginx2 status    或使用  systemctl status nginx2ps -ef|grep nginx2service nginx2 stop    或使用  systemctl stop nginx2
4. 配置nginx环境变量
cat >>/etc/profile<<EOFNGINX_HOME=/usr/local/nginxPATH=\$NGINX_HOME/sbin:\$PATH NGINX2_HOME=/usr/local/nginx2PATH=\$NGINX2_HOME/sbin:\$PATHEOFsource /etc/profile

标签: #nginxcgibin