Linux系统_Centos7下安装Nginx

下载Nginx
wget http://nginx.org/download/nginx-1.15.5.tar.gz
解压
tar -xzvf nginx-1.15.5.tar.gz 

生成Makefile,为下一步的编译做准备(可以根据需要删减参数)

./configure --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-stream  --with-stream_ssl_module --with-pcre

安装出现的问题
hecking for C compiler ... not found
./configure: error: C compiler cc is not found

异常:缺失gcc
解决方案
yum -y install gcc gcc-c++ autoconf automake make

异常:缺失PCRE

error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using 
解决
yum -y install pcre-devel

异常:缺失OpenSSL

 error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option
解决:
yum -y install openssl openssl-devel

编译安装
make && make install


按指定配置文件启动Nginx
nginx -c /usr/local/nginx/conf/nginx.conf 
停止操作是通过向nginx进程发送信号来进行的
步骤1:查询nginx主进程号ps -ef | grep nginx
在进程列表里 面找master进程,它的编号就是主进程号了。
步骤2:发送信号

从容停止Nginx:
kill -QUIT 主进程号  
例如:kill -QUIT 16391

快速停止Nginx:
kill -TERM 主进程号  

强制停止Nginx:
kill -9 主进程号  

平滑重启

如果更改了配置就要重启Nginx,要先关闭Nginx再打开?不是的,可以向Nginx 发送信号,平滑重启。
平滑重启命令:
kill -HUP 住进称号或进程号文件路径  
或者使用
/usr/nginx/sbin/nginx -s reload  
注意,修改了配置文件后最好先检查一下修改过的配置文件是否正确,
以免重启后Nginx出现错误影响服务器稳定运行。判断Nginx配置是否正确命令如下:
nginx -t -c /usr/nginx/conf/nginx.conf 
或者
/usr/nginx/sbin/nginx -t 

使用浏览器访问localhost,出现如下页面说明安装成功

153fa0af6a6b915c8cfc26578d44bc1cdfd.jpg

转载于:https://my.oschina.net/sky2008/blog/2248949

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值