美文网首页
在CentOS 7 安装 Nginx 1.10.1

在CentOS 7 安装 Nginx 1.10.1

作者: zeroLL | 来源:发表于2016-12-07 09:44 被阅读296次
    1. cd /usr/local
    2. 安装GCC 和GCC-C++
        yum install gcc
        yum install -y gcc gcc-c++
    
    1. 安装pcre库
    cd /usr/local/
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
    tar -zxvf pcre-8.39.tar.gz
    cd pcre-8.39/
    ./configure
    make
    make install
    
    1. 安装zlib库
    cd /usr/local/ 
    wget http://zlib.net/zlib-1.2.8.tar.gz
    tar -zxvf zlib-1.2.8.tar.gz
    cd zlib-1.2.8/
    ./configure
    make
    make install
    
    1. 安装ssl
    cd /usr/local/
    wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
    tar -zxvf openssl-1.0.1c.tar.gz
    cd openssl-1.0.1c
    ./config
    make
    make install
    

    按上面的操作,openssl报错,我再次更新了一下openssl
    yum -y install openssl openssl-devel

    1. 安装nginx
    cd /usr/local/
    wget http://nginx.org/download/nginx-1.10.1.tar.gz
    tar -zxvf nginx-1.10.1.tar.gz
    cd nginx-1.10.1/
    

    为了支持wss,我添加了--with-stream --with-stream_ssl_module

    ./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-stream --with-stream_ssl_module --with-http_flv_module --with-http_mp4_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre=/usr/local/pcre-8.39 --with-zlib=/usr/local/zlib-1.2.8
    
    make
    make install
    
    1. 启动 nginx
      /usr/local/nginx/sbin/nginx

    如果 nginx: [emerg] getpwnam("nginx") failed 执行一下面两行

    useradd -s /sbin/nologin -M nginx
    id nginx
    

    应该会出现
    uid=1000(nginx) gid=1000(nginx) 组=1000(nginx)

    如果 nginx: [emerg] mkdir() "/var/tmp/nginx/client/" failed (2: No such file or directory) 执行下面两行

    cd /var/tmp/
    mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
    

    再一次,没有任何提示就表示成功
    /usr/local/nginx/sbin/nginx

    1. 输入http://localhost/

    注:配置文件在/etc/nginx/nginx.conf

    相关文章

      网友评论

          本文标题:在CentOS 7 安装 Nginx 1.10.1

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