一台服务器上安装多台Nginx

1、确认系统中是否安装了gcc、pcre-devel、zlib-devel、openssl-devel

rpm -qa|grep gcc
rpm -qa|grep pcre-devel
rpm -qa|grep zlib-devel
rpm -qa|grep openssl-devel

如果没有安装则进行第二步,否则进入第三步
2、使用yum安装gcc、pcre-devel、zlib-devel、openssl-devel

yum install -y gcc、pcre-devel、zlib-devel、openssl-devel

3、解压

tar zxvf nginx-1.11.6.tar.gz

4、进入解压的目录

cd nginx-1.11.6

5、编译

./configure \
--prefix=/usr/local/nginx2 \
--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 \
--pid-path=/usr/local/nginx2/logs/nginx2.pid \
--lock-path=/var/run/nginx2.lock \
--http-client-body-temp-path=/usr/local/nginx2/client_body_temp \
--http-proxy-temp-path=/usr/local/nginx2/proxy_temp \
--http-fastcgi-temp-path=/usr/local/nginx2/fastcgi_temp \
--http-uwsgi-temp-path=/usr/local/nginx2/uwsgi_temp \
--http-scgi-temp-path=/usr/local/nginx2/scgi_temp \
--user=nginx2 \
--group=nginx2 \
--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

安装多个nginx则需要多次执行该步骤,但是每次执行的路径不一样
6、编译安装

make && make install

7、编译完成后进入nginx的安装目录,启动nginx
7.1 首先添加nginx用户

useradd -s /sbin/nologin -M nginx3

7.2 使用指定nginx.conf文件的方式重启nginx

/usr/local/nginx3/sbin/nginx3 -c /usr/local/nginx3/conf/nginx.conf

7.3 结束当前nginx进程

 Killall nginx3
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

IT老猫讲编程

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值