zoukankan      html  css  js  c++  java
  • CentOs7.2编译安装Nginx服务器

    1. 安装nginx依赖

    首先安装nginx的依赖

    yum install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md5

    2,创建nginx用户

    如果没有nginx,启动nginx时会报错

    [root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx
    nginx: [emerg] getpwnam("nginx") failed
    因此执行
    groupadd nginx
    useradd -s /sbin/nologin -g nigix -M nginx

    3,下载最新版nginx安装包

    wget -C http://nginx.org/download/nginx-1.12.0.tar.gz

    4,解压

    tar zxvf nginx-1.12.0.tar.gz

    5,进入nginx目录

    cd nginx-1.12.0

    6,编译设置

    ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module

    因此要顺利的通过nginx编译安装必须安装的依赖关系有:

    yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

    如果有错误提示:./configure: error: C compiler cc is not found

    解决方法:

    yum install gcc gcc-c++

    如果有错误提示:./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.

    解决方法:

    yum install pcre-devel

    如果有错误提示:./configure: 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 install openssl-devel
    7,编译&安装
    make & make install

    8,nginx直接启动方法
    /usr/local/nginx/sbin/nginx

     9,现在我们将nginx加入到环境变量中

    vi /etc/profile 

    随后我们更新环境变量 并使用命令再次重启nginx

    这时已经不再报错了

    写在结尾:可能会出现没有pid文件的情况

     ps -ef|grep nginx
    过滤出nginx的进程号,然后在配置文件中 pid配置目录创建一个pid文件,里面填写nginx的进程号就可以了。

    [emerg]: getpwnam(“nginx”) failed

     
    1
    2
    [root@localhost nginx-1.11.2]# /usr/local/nginx/sbin/nginx
    nginx: [emerg] getpwnam("nginx") failed
  • 相关阅读:
    LInux 安全测试 2
    LInux 安全测试
    又一款linux提权辅助工具
    shell 生成指定范围随机数与随机字符串 .
    腾讯新浪通过IP地址获取当前地理位置(省份)的接口
    建站指南:百度认为什么样的网站更有抓取和收录价值2012-06-20
    ngx_lua 金山项目 黄雀
    在页面中使用js
    多线程取读文件(别人的,有点晕,先放在这里有时间研究研究)
    factory工厂模式
  • 原文地址:https://www.cnblogs.com/pcyy/p/8834851.html
Copyright © 2011-2022 走看看