如果没有安装过nginx请看:linux下nginx部署以及配置详解

1、第一个nginx已经安装完成后,现在安装第二个nginx

启动:sudo /usr/sbin/nginx3
重起:sudo /usr/sbin/nginx3 -s reload
停止:sudo /usr/sbin/nginx3 -s stop

一、进入nginx目录进行编译安装

1、切换目录:

cd /usr/local/src/nginx-1.16.
安装第二个路径会有所不同,我这里安装的是第三个nginx3,如果要安装4个 就改为nginx4,需要注意nginx.conf不需要改变,命令如下:
./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

执行完后下面就是nginx3的路径

2、安装编译:

make && make install
mkdir -pv /var/tmp/nginx3/client

3、添加SysV启动脚本

vi /etc/init.d/nginx3

按i进入编辑状态,需要多个nginx修改以下两个路径即可,如图

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: -
# 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
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
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
killall - nginx
}
restart() {
configtest || return $?
stop
sleep
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 >&
}
case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac

4.赋予脚本执行权限

chmod +x /etc/init.d/nginx3

8.添加nginx服务进程用户

groupadd -r nginx3
useradd -r -g nginx nginx3

9、添加至服务管理列表,设置开机自启

chkconfig --add nginx3
chkconfig nginx3 on

10、修改nginx.conf端口号,我这里改为81

vi /etc/nginx3/nginx.conf

11、启动nginx3

/usr/sbin/nginx3

查看端口号
netstat -lntp

11、在启动一个nginx

12、停止nginx3

sudo /usr/sbin/nginx3 -s stop

在linux系统下安装两个nginx以及启动、停止、重起的更多相关文章

  1. linux系统下安装两个或多个tomcat

    编辑环境变量:vi /etc/profile 加入以下代码(tomcat路径要配置自己实际的tomcat安装目录) ##########first tomcat########### CATALINA ...

  2. linux系统下安装两个或多个tomcat(转)

    tomcat不用添加到环境变量中 直接解压两个tomcat   来到第二个tomcat的conf目录下 打开server.xml更改端口: 修改server.xml配置和第一个不同的启动.关闭监听端口 ...

  3. 在Linux系统下安装大于mysql5.5版本的数据库

    linux下mysql 5.5的安装方法: 1.安装所需要系统库相关库文件      gcc等开发包,在安装linux系统的时候安装. 2.创建mysql安装目录 # mkdir -p /usr/lo ...

  4. Linux 系统下安装 rz/sz 命令及使用说明

    Linux 系统下安装 rz/sz 命令及使用说明 rz/sz命令,实现将本地的文件上传到服务器或者从服务器上下载文件到本地,但是很多Linux系统初始并没有这两个命令,以下为安装和使用的具体步骤: ...

  5. Linux系统下安装Redis和Redis集群配置

    Linux系统下安装Redis和Redis集群配置 一. 下载.安装.配置环境: 1.1.>官网下载地址: https://redis.io/download (本人下载的是3.2.8版本:re ...

  6. 在虚拟机的Linux系统下安装wineqq

    |   版权声明:本文为博主原创文章,未经博主允许不得转载. 本文参考教程:http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread& ...

  7. 【linux配置】Linux系统下安装rz/sz命令以及使用说明

    Linux系统下安装rz/sz命令以及使用说明 对于经常使用Linux系统的人员来说,少不了将本地的文件上传到服务器或者从服务器上下载文件到本地,rz / sz命令很方便的帮我们实现了这个功能,但是很 ...

  8. Linux 系统下安装 python-skimage

    Linux 系统下安装 python-skimage 安装必须的依赖 // python-mumpy // python-scipy // python-matplotlib $ sudo apt-g ...

  9. Linux系统下安装Gitlab

    Linux系统下安装Gitlab 一.简介 GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目.它拥有与 ...

随机推荐

  1. git 初始用法

    Git global setup git config --global user.name "xiaoming" git config --global user.email & ...

  2. Java中的锁原理、锁优化、CAS、AQS详解!

    阅读本文大概需要 2.8 分钟. 来源:jianshu.com/p/e674ee68fd3f 一.为什么要用锁? 锁-是为了解决并发操作引起的脏读.数据不一致的问题. 二.锁实现的基本原理 2.1.v ...

  3. 定时任务、js定时任务

    intervalID =setInterval("getIsCookie()",1000); //开始任务 clearInterval(intervalID);//停止任务

  4. 创建第一个react项目

    前提:已安装部署好nodejs环境 查看nodejs是否安装以及版本 1,win+r输入cmd打开命令行页面 2,路径换到nodejs目录 3,输入node -v查看版本 创建项目 1,win+r输入 ...

  5. [Beta阶段]发布说明

    小小易校园微信小程序发布说明 第二版小小易校园小程序发布啦~ 打开微信,点击右上角➕,选择扫一扫,扫描以下二维码即可进入小程序: 版本功能: 上一版功能请参见[Alpha阶段]发布说明. 当前版本的更 ...

  6. java wait方法

    wait方法是让当前线程等待,这里的当前线程不是指t,而是主线程. wait会释放锁,等到其他线程调用notify方法时再继续运行. 可以看下面的例子. 1 package com.citi.test ...

  7. Spark2.x(六十一):在Spark2.4 Structured Streaming中Dataset是如何执行加载数据源的?

    本章主要讨论,在Spark2.4 Structured Streaming读取kafka数据源时,kafka的topic数据是如何被执行的过程进行分析. 以下边例子展开分析: SparkSession ...

  8. C++11原子操作与无锁编程(转)

    不讲语言特性,只从工程角度出发,个人觉得C++标准委员会在C++11中对多线程库的引入是有史以来做得最人道的一件事:今天我将就C++11多线程中的atomic原子操作展开讨论:比较互斥锁,自旋锁(sp ...

  9. 通过 UNSAFE 来实现一个 Atomic 的 CAS 辅助类【原创】

    public abstract class AbstractUnSafeCas<T> { @SuppressWarnings("unused") private vol ...

  10. git rebase命令

    使用git rebase合并多次commit. 当年提交代码后,管理员发现,你的代码不能提交到服务器上,注意原因在于,你的commit中的commit和服务器中的有些commit不在同一时间轴上,即: ...