zoukankan      html  css  js  c++  java
  • 编译安装NGINX1.16.1

    一、编译前提,需要安装必要的包

    yum install gcc pcre-devel openssl-devel zlib-devel  wget -y

    (wget不是编译必须的,只是我后面要下载东西用,就一起安装)

    二、下载对应的NGINX包

    wget http://nginx.org/download/nginx-1.16.1.tar.gz

    三、创建nginx用户

    useradd -r -s /sbin/nologin nginx

    四、解压nginx到/data/下

    tar xvf  nginx-1.16.1.tar.gz -C /data/

    (路径自定义)

    五、进入解压的nginx目录中

    cd /data/nginx-1.16.1/

    六、编译安装

    ./configure --prefix=/apps/nginx 
    --user=nginx 
    --group=nginx 
    --with-http_ssl_module 
    --with-http_v2_module 
    --with-http_realip_module 
    --with-http_stub_status_module 
    --with-http_gzip_static_module 
    --with-pcre 
    --with-stream 
    --with-stream_ssl_module 
    --with-stream_realip_module

    计划安装的路径在/apps/

    七、开始编译

    make -j 2 && make install

    -j 2 表示CPU两核,可以按照实际CPU核数定义,越多越快

    八、为了方便启动可以创建软链接或者修改PATH变量

    ln -s /apps/nginx/sbin/nginx /usr/sbin/

    九、开启nginx

    nginx

    十、测试访问

    [18:50:22 root@localhost ~]#curl 192.168.1.4
    <!DOCTYPE html>
    <html>
    <head>
    <title>Welcome to nginx!</title>
    <style>
        body {
             35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>
    </head>
    <body>
    <h1>Welcome to nginx!</h1>
    <p>If you see this page, the nginx web server is successfully installed and
    working. Further configuration is required.</p>
    
    <p>For online documentation and support please refer to
    <a href="http://nginx.org/">nginx.org</a>.<br/>
    Commercial support is available at
    <a href="http://nginx.com/">nginx.com</a>.</p>
    
    <p><em>Thank you for using nginx.</em></p>
    </body>
    </html>

    十一、设置为开机自启动

      1、修改centos7自带的开机自启动文件中

    vim  /etc/rc.d/rc.local 

      2、添加NGINX的路径

    /usr/sbin/nginx

      3、这个文件默认没有执行权限,添加执行权限

    chmod +x /etc/rc.d/rc.local 

    十二、停止nginx服务

    nginx -s stop

    十三、NGINX 的其他命令点击此处查看

    ------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------- 博客均为个人笔记,无所追求,仅供参考~~~ QQ--2382990774
  • 相关阅读:
    《构建之法》阅读笔记4
    团队冲刺第七天
    团队冲刺第六天
    团队冲刺第五天
    团队冲刺第四天
    团队冲刺第三天
    构建之法阅读笔记03
    第十四周进度条
    第二阶段冲刺站立会议10
    第二阶段冲刺站立会议09
  • 原文地址:https://www.cnblogs.com/alexlv/p/14819045.html
Copyright © 2011-2022 走看看