zoukankan      html  css  js  c++  java
  • linux CentOS 安装 nginx

     

    官方网址:http://nginx.org/en/download.html

    一、安装基础组件

    yum install gcc-c++

    yum install pcre

    yum install pcre-devel

    yum install zlib 

    yum install zlib-devel

    yum install openssl

    yum install openssl-devel

    二、安装Nginx

    第一种:下载安装:

    wget http://nginx.org/download/nginx-1.15.9.tar.gz
    tar -zxvf nginx-1.15.9.tar.gz
    #cd nginx-1.10.3
    
    ./configure
    
    make
    

     

    make install
    
    ./nginx 
    ./nginx -s stop
    ./nginx -s quit
    ./nginx -s reload
    

    配置nginx开机启动

    cd /lib/systemd/system/
    vim nginx.service
    

    切换到/lib/systemd/system/目录,创建nginx.service文件vim nginx.service

    [Unit]
    Description=nginx 
    After=network.target 
       
    [Service] 
    Type=forking 
    ExecStart=/usr/local/nginx/sbin/nginx
    ExecReload=/usr/local/nginx/sbin/nginx reload
    ExecStop=/usr/local/nginx/sbin/nginx quit
    PrivateTmp=true 
       
    [Install] 
    WantedBy=multi-user.target
    

    退出并保存文件,执行systemctl enable nginx.service使nginx开机启动

    systemctl enable nginx.service
    

    systemctl start nginx.service    启动nginx

    systemctl stop nginx.service    结束nginx

    systemctl restart nginx.service    重启nginx

    第二种:YUM安装:

    查看yum库中的 nginx安装包

    yum -y list nginx*
    

    安装yum库中的 nginx

    安装源:yum install nginx-release-centos-6-0.el6.ngx.noarch.rpm -y(注意-y参数)

    安装Nginx:yum install nginx

    启动Nginx服务:service nginx start

    停止Nginx服务:service nginx stop

    查看Nginx运行状态:service nginx status

    检查Nginx配置文件:nginx -t

    服务运行中重新加载配置:nginx -s reload

    添加Nginx服务自启动:chkconfig nginx on

  • 相关阅读:
    UWP AppConnection.
    Qt 多线程使用moveToThread
    C#综合细说进程、应用程序域与上下文
    C++ std::function
    商品价格加价区间的实现(策略模式)
    学习web前端三个月感悟
    triangle leetcode C++
    Linux入门视频
    轻松学习Linux之进程监视与管理
    阻止缓冲区溢出攻击
  • 原文地址:https://www.cnblogs.com/haiyabtx/p/10547943.html
Copyright © 2011-2022 走看看