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

    来源:https://blog.csdn.net/stinkstone/article/details/78082748

    1.下载地址:
    http://nginx.org/en/download.html

    # cd /usr/local
    # wget http://nginx.org/download/nginx-1.11.5.tar.gz

    2.先执行以下命令,安装nginx依赖库,如果缺少依赖库,可能会安装失败,具体可以参考文章后面的错误提示信息

    # 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

    3.解压安装包

    # tar -zxvf nginx-1.11.5.tar.gz

    4.nginx被解压到了/usr/local/nginx-1.11.5 目录下(不要把压缩包解压到/usr/local/nginx目录下,或者将解压后的目录重命名为nginx,因为nginx会默认安装到/usr/local/nginx目录下),切换到nginx-1.11.5/目录

    # cd /usr/local/nginx-1.11.5/

    5.执行# ./configure

    # ./configure

    该操作会检测当前系统环境,以确保能成功安装nginx,执行该操作后可能会出现以下几种提示:

    checking for OS
    
         + Linux 3.10.0-123.el7.x86_64 x86_64
    
        checking for C compiler ... not found
    
        ./configure: error: C compiler cc is not found
    
        1.如果出现以上错误提示信息,执行yum install gcc-c++安装gcc,
    
        ./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.
    
        2.如果出现上面提示,表示缺少PCRE库
    
        ./configure: error: the HTTP gzip module requires the zlib library.
    
        You can either disable the module by using --without-http_gzip_module
    
        option, or install the zlib library into the system, or build the zlib library
    
        statically from the source with nginx by using --with-zlib=<path> option.
    
        3.如果出现以上提示,表示缺少zlib库
    
        

    6.如果没有出现./configure: error提示,表示当前环境可以安装nginx,执行make和make install编译nginx

    # make
    # make install
    没有出错的话,表示nginx已经成功安装完成,默认安装位置为/usr/local/nginx,之前的/usr/local/nginx-1.11.5/可以删除掉了。

    7.配置nginx开机启动

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

    # cd /lib/systemd/system/
    # 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

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

    # systemctl enable nginx.service
  • 相关阅读:
    第十五节课:习题讲解
    第十四节课:字典
    Python第十三节课-文件的读取和写入
    Python第十二节课--循环语句与注释
    Python第十一节课--字符串的格式化
    Python第十节课==对象的方法
    Python第九节课--初识函数
    初识函数--文件的读取和打开,已一节课一节课分开,可不看
    刷题647. Palindromic Substrings
    刷题617. Merge Two Binary Trees
  • 原文地址:https://www.cnblogs.com/big-cut-cat/p/11624212.html
Copyright © 2011-2022 走看看