• nginx安装2


    下载

    从http://nginx.org/download/上下载相应的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下载)

    解压

    解压 tar -zxvf nginx-1.5.9.tar.gz 

    解压好后移至目录

    [root@instance-3lm099to nginx]# cd nginx-1.5.9/

    设置Nginx安装路径,如果没有指定,默认为/usr/local/nginx

    [root@instance-3lm099to nginx-1.14.0]# ./configure --prefix=/usr/local/nginx
    checking for OS
     + Linux 3.10.0-862.3.2.el7.x86_64 x86_64
    checking for C compiler ... not found

    如果出现红色字体错误,需要执行下

    [root@instance-3lm099to nginx-1.14.0]# yum -y install gcc gcc-c++ autoconf automake make

    再次执行

    [root@instance-3lm099to nginx-1.14.0]# ./configure --prefix=/usr/local/nginx

    可能会出现这个错误

    ./configure: 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 --with-pcre=<path> option.

    如果出现了,就执行下这个

    [root@instance-3lm099to nginx-1.14.0]# yum -y install openssl openssl-devel

    再次执行

    [root@instance-3lm099to nginx-1.14.0]# ./configure --prefix=/usr/local/nginx

    启动

    参数 -c 指定了配置文件的路径,如果不加的话就是使用默认的配置文件

    [root@instance-3lm099to nginx-1.14.0]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    停止

    停止操作是通过向nginx进程发送信号(什么是信号请参阅linux文 章)来进行的

    查询nginx主进程号

    ps -ef | grep nginx
    在进程列表里 面找master进程,它的编号就是主进程号了。

    发送信号

    从容停止Nginx

    kill -QUIT 主进程号

    快速停止Nginx

    kill -TERM 主进程号

    强制停止Nginx

    pkill -9 nginx

    另外, 若在nginx.conf配置了pid文件存放路径则该文件存放的就是Nginx主进程号,如果没指定则放在nginx的logs目录下。有了pid文 件,我们就不用先查询Nginx的主进程号,而直接向Nginx发送信号了,命令如下:
    kill -信号类型 '/usr/nginx/logs/nginx.pid'

    平滑重启

    如果更改了配置就要重启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
  • 相关阅读:
    尝试制作了一个Panorama
    Python小游戏之猜数字
    Java基础-多线程学习目录
    Java8学习笔记目录
    Guava学习笔记目录
    Angular4学习笔记-目录汇总
    Springboot学习笔记
    JavaWeb-Tomcat阀
    JavaWeb-Tomcat安全域
    JavaWeb-Servlet基础
  • 原文地址:https://www.cnblogs.com/wangzhanhua/p/11527317.html
Copyright © 2020-2023  润新知