Linux系统_Centos7下安装Nginx

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

生成Makefile,为下一步的编译作准备(能够根据须要删减参数)c++

./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 makeui

异常:缺失PCREblog

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进程

异常:缺失OpenSSLip

 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-develssl

编译安装
make && make installget


按指定配置文件启动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,出现以下页面说明安装成功

相关文章
相关标签/搜索