美文网首页
nginx 安装

nginx 安装

作者: 米古月_f198 | 来源:发表于2020-12-18 09:44 被阅读0次
    1. wget http://nginx.org/download/nginx-1.16.1.tar.gz # 演示版本
    2. tar -xzf nginx-1.16.1.tar.gz
    3. cd nginx-1.16.1
    4. ./configure # 准备 编译Nginx

    报错
    ./configure: error: C compiler cc is not found
    安装
    yum -y install gcc gcc-c++ autoconf automake make

    报错
    ./configure: error: the HTTP rewrite module requires the PCRE library.
    安装
    yum install -y pcre pcre-devel

    报错
    ./configure: error: the HTTP gzip module requires the zlib library.
    安装
    yum install -y zlib zlib-devel

    安装好这两个之后就可以安装nginx了,但是如果安装的时候有问题的话可能需要安装GCC和OpenSSL以下提供命令

    yum install gcc-c++
    yum install -y openssl openssl-devel

    编译安装

    make
    make install

    查看是否安装好
    ps -ef|grep nginx

    运行
    进入nginx/sbin
    执行./nginx

    nginx安装目录地址 -c nginx配置文件地址

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
    停止

    nginx的停止有三种方式

    从容停止
    ps -ef|grep nginx

    image

    杀死进程 kill -QUIT 3905
    快速停止 kill -TERM 3905
    或者 kill -INT 3905
    强制停止 pkill -9 nginx

    重启

    方法一:进入nginx可执行目录sbin下,输入命令./nginx -s reload 即可

    image

    方法二:查找当前nginx进程号,然后输入命令:kill -HUP进程号 实现重启

    image

    sudo nginx -s quit 退出
    sudo nginx -s reload 重新加载

    于是查看nginx日志,路径为/var/log/nginx/error.log。打开日志发现报错Permission denied,详细报错如下:

    1. open() "/data/www/1.txt" failed (13: Permission denied), client: 192.168.1.194, server: www.web1.com, request: "GET /1.txt HTTP/1.1", host: "www.web1.com"

    没有权限?于是找了不少资料,可以通过下面四步排查解决此问题。你可能只是其中之前配置有问题,不一定四个步骤都用上。

    cd ../usr/local/nginx/sbin

    ./nginx -s quit

    ./nginx

    一、由于启动用户和nginx工作用户不一致所致

    1.1查看nginx的启动用户,发现是nobody,而为是用root启动的
    修改nginx.conf顶部nobody改为root

    permission denied
    chmod -R 777 文件夹

    【部署问题】解决Nginx: [error] open() "/usr/local/Nginx/logs/Nginx.pid" failed(2:No such file or directory)

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

    完整
    https://www.cnblogs.com/ghzjm/p/10677599.html

    相关文章

      网友评论

          本文标题:nginx 安装

          本文链接:https://www.haomeiwen.com/subject/huszgktx.html