在linux系统下安装两个nginx以及启动、停止、重起
如果没有安装过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以及启动、停止、重起的更多相关文章
- linux系统下安装两个或多个tomcat
编辑环境变量:vi /etc/profile 加入以下代码(tomcat路径要配置自己实际的tomcat安装目录) ##########first tomcat########### CATALINA ...
- linux系统下安装两个或多个tomcat(转)
tomcat不用添加到环境变量中 直接解压两个tomcat 来到第二个tomcat的conf目录下 打开server.xml更改端口: 修改server.xml配置和第一个不同的启动.关闭监听端口 ...
- 在Linux系统下安装大于mysql5.5版本的数据库
linux下mysql 5.5的安装方法: 1.安装所需要系统库相关库文件 gcc等开发包,在安装linux系统的时候安装. 2.创建mysql安装目录 # mkdir -p /usr/lo ...
- Linux 系统下安装 rz/sz 命令及使用说明
Linux 系统下安装 rz/sz 命令及使用说明 rz/sz命令,实现将本地的文件上传到服务器或者从服务器上下载文件到本地,但是很多Linux系统初始并没有这两个命令,以下为安装和使用的具体步骤: ...
- Linux系统下安装Redis和Redis集群配置
Linux系统下安装Redis和Redis集群配置 一. 下载.安装.配置环境: 1.1.>官网下载地址: https://redis.io/download (本人下载的是3.2.8版本:re ...
- 在虚拟机的Linux系统下安装wineqq
| 版权声明:本文为博主原创文章,未经博主允许不得转载. 本文参考教程:http://www.ubuntukylin.com/ukylin/forum.php?mod=viewthread& ...
- 【linux配置】Linux系统下安装rz/sz命令以及使用说明
Linux系统下安装rz/sz命令以及使用说明 对于经常使用Linux系统的人员来说,少不了将本地的文件上传到服务器或者从服务器上下载文件到本地,rz / sz命令很方便的帮我们实现了这个功能,但是很 ...
- Linux 系统下安装 python-skimage
Linux 系统下安装 python-skimage 安装必须的依赖 // python-mumpy // python-scipy // python-matplotlib $ sudo apt-g ...
- Linux系统下安装Gitlab
Linux系统下安装Gitlab 一.简介 GitLab是利用 Ruby on Rails 一个开源的版本管理系统,实现一个自托管的Git项目仓库,可通过Web界面进行访问公开的或者私人项目.它拥有与 ...
随机推荐
- Cookie 的 SameSite 属性
转自http://www.ruanyifeng.com/blog/2019/09/cookie-samesite.html Chrome 51 开始,浏览器的 Cookie 新增加了一个SameSit ...
- 关于python的四舍五入
参考https://blog.csdn.net/qq_39234705/article/details/82817703 四舍五入有很多相关资料,主要用两种方法round()和'%.2f' 两种方法取 ...
- SLF4J使用,slf4j-api、slf4j-log4j12以及log4j的关系
SLF4J不同于其他日志类库,与其它有很大的不同.SLF4J(Simple logging Facade for Java)不是一个真正的日志实现,而是一个抽象层( abstraction layer ...
- jsch配置sftp服务器ssh免密登录
前期对接了一个通过ssh免密登录的需求,是基于原先密码登录sftp服务器的代码上进行改造,实际上代码改动量非常少,趁此机会对自己整理的资料做一下总结. 1. 什么是SFTP SFTP是一个安全文件传送 ...
- Feign进行文件上传+表单调用
Feigin默认是不支持文件上传和表单提交的,需要做一些配置才能支持. 1.feign依赖 图中红色为form支持必须的jar. 2.添加自定义Encoder类: import static java ...
- [转]iview的render函数用法
原文地址:https://www.jianshu.com/p/f593cbc56e1d 一.使用html的标签(例如div.p) 原生标签用法 二.使用iview的标签(例如Button) iview ...
- 从 SVN 迁移至 Git 并保留所有 commit 记录
yum install -y git-svn 用户映射文件user.txt,等号左边为svn账号,右边为Git用户名和邮箱.注意:svn中有多少用户就要映射多少 test1=test1<1472 ...
- Celery 服务搭建
整个项目工程如下 __init__.py """ 注意点:python3.7 需要执行 pip install --upgrade https://github.com/ ...
- 国内pip源及pip命令
更换PIP源 PIP源在国外,速度慢,可以更换为国内源,以下是国内一些常用的PIP源. 豆瓣(douban) http://pypi.douban.com/simple/ (推荐) 清华大学 http ...
- WSL记录
cmder(mini版)作为wsl的终端,很好用,可以split屏.但是:千万不要在settings里面设置start up(启动) 里面设置 命令行“bash -cur_console:p1”!目前 ...