zoukankan      html  css  js  c++  java
  • linux入门常用指令2.安装nginx

    下载nginx包

    nginx-1.10.3.tar.gz

    解压

    [root@localhost src]# tar -zxvf nginx-1.10.3.tar.gz 
    [root@localhost src]# cd nginx-1.10.3
    [root@localhost nginx-1.10.3]# ./configure 
    checking for OS
     + Linux 3.10.0-229.el7.x86_64 x86_64
    checking for C compiler ... not found
    ./configure: error: C compiler cc is not found
    
    

    安装gcc编译环境

    [root@localhost nginx-1.10.3]# yum install gcc-c++
    已安装:
      gcc-c++.x86_64 0:4.8.3-9.el7 
    作为依赖被安装:
      cpp.x86_64 0:4.8.3-9.el7                 gcc.x86_64 0:4.8.3-9.el7                   glibc-devel.x86_64 0:2.17-78.el7    
      glibc-headers.x86_64 0:2.17-78.el7       kernel-headers.x86_64 0:3.10.0-229.el7     libmpc.x86_64 0:1.0.1-3.el7         
      libstdc++-devel.x86_64 0:4.8.3-9.el7     mpfr.x86_64 0:3.1.1-4.el7      
    

    安装依赖包

    如果直接安装会包错
    ./configure: error: the HTTP rewrite module requires the PCRE library.
    [root@localhost nginx-1.10.3]# yum install pcre pcre-devel -y
    [root@localhost nginx-1.10.3]# yum install zlib zlib-devel -y
    [root@localhost nginx-1.10.3]# yum install openssl openssl--devel -y
    

    安装nginx

    #配置检测 指定安装目录
    [root@localhost nginx-1.10.3]# ./configure --prefix=/usr/local/nginx
        Configuration summary
        + using system PCRE library
        + OpenSSL library is not used
        + using builtin md5 code
        + sha1 library is not found
        + using system zlib library
    
        nginx path prefix: "/usr/local/nginx"
        nginx binary file: "/usr/local/nginx/sbin/nginx"
        nginx modules path: "/usr/local/nginx/modules"
        nginx configuration prefix: "/usr/local/nginx/conf"
        nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
        nginx pid file: "/usr/local/nginx/logs/nginx.pid"
        nginx error log file: "/usr/local/nginx/logs/error.log"
        nginx http access log file: "/usr/local/nginx/logs/access.log"
        nginx http client request body temporary files: "client_body_temp"
        nginx http proxy temporary files: "proxy_temp"
        nginx http fastcgi temporary files: "fastcgi_temp"
        nginx http uwsgi temporary files: "uwsgi_temp"
        nginx http scgi temporary files: "scgi_temp"
    #编译    
    [root@localhost nginx-1.10.3]# make
    #安装
    [root@localhost nginx-1.10.3]# make install
    

    启动nginx

    #启动
    [root@localhost /]# /usr/local/nginx/sbin/nginx 
    #重启
    [root@localhost /]# /usr/local/nginx/sbin/nginx -s reload
    #关闭
    [root@localhost /]# /usr/local/nginx/sbin/nginx  -s stop
    #启动成功
    [root@localhost nginx]#  ps -axu|grep nginx
    root      17003  0.0  0.0  20432   604 ?        Ss   22:11   0:00 nginx: master process /usr/local/nginx/sbin/nginx
    
    #查看防火墙状态
    [root@localhost nginx]# firewall-cmd --state
    #关闭防火墙服务
    [root@localhost nginx]# systemctl stop firewalld 
    

    开机启动

    [root@localhost nginx]# vim /lib/systemd/system/nginx.service
        [Unit]
            Description=nginx
            After=network.target
            
            [Service]
            Type=forking
            ExecStart=/usr/local/nginx/sbin/nginx
            ExecReload=/usr/local/nginx/sbin/nginx -s reload
            ExecStop=/usr/local/nginx/sbin/nginx -s quit
            PrivateTmp=true
            
            [Install]
            WantedBy=multi-user.target
    
    #设置开机启动
    [root@localhost nginx]# systemctl enable nginx.service
    #停止开机自启动
    [root@localhost nginx]# systemctl disable nginx.service
    
  • 相关阅读:
    原型链加强练习
    Javascript中的原型链,__proto__和prototype等问题总结
    HTTPS 到底加密了什么?
    PrismCDN 网络的架构解析,以及低延迟、低成本的奥秘
    取代 FlashP2P,H5P2P 将成为 WebP2P 主流
    低延时的P2P HLS直播技术实践
    深挖“窄带高清”的实现原理
    【省带宽、压成本专题】爱奇艺第一季度又烧了11个亿元,什么时候是个头?
    【省带宽、压成本专题】深入解析 H.265 编码模式,带你了解 Apple 全面推进 H.265 的原因
    让互联网更快,Server Push 特性及开启方式详解
  • 原文地址:https://www.cnblogs.com/web369/p/10985512.html
Copyright © 2011-2022 走看看