加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > CentOS > 正文

centOs 7 安装 Nginx

发布时间:2020-05-22 11:33:15 所属栏目:CentOS 来源:互联网
导读:安装过程 先去下载一个nginxNginx官方下载地址 我在里面随便找一个比较新的版本,注意,我们要下载*.tar.gz的源码安装包。就:nginx-1.9.5.tar.gz版本吧 在cent os下面直接下载: [html] view plain copy wgethttp://nginx.org/download/nginx-1.10.2.tar.gz

安装过程

先去下载一个nginxNginx官方下载地址
我在里面随便找一个比较新的版本,注意,我们要下载*.tar.gz的源码安装包。就:nginx-1.9.5.tar.gz版本吧
在cent os下面直接下载:

[html] view plain copy
  1. wgethttp://nginx.org/download/nginx-1.10.2.tar.gz
  2. tar-zxvfnginx-1.10.2.tar.gz
  3. cdnginx-1.10.2/
  4. make
  5. makeinstall
  6. #安装地址的绝对路径
  7. #/usr/local/nginx
  8. /configure--prefix=/usr/local/nginx



异常报错解决办法

Q:

copy ./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.
  • Youcaneitherdisablethemodulebyusing--without-http_rewrite_module
  • option,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrary
  • A:

    yum -y install pcre-devel


    Q:

    copy ./configure:error:theHTTPgzipmodulerequiresthezliblibrary.
  • Youcaneitherdisablethemodulebyusing--without-http_gzip_modul
  • install-yzlib-devel
  • copy nginx:[alert]couldnotopenerrorlogfile:open()"/usr/local/nginx//logs/error.log"failed(13:Permissiondenied)

    A: sudo yum install -y zlib-devel

    Q:

    copy nginx:[emerg]bind()to0.0.0.0:80failed(98:Addressalreadyinuse)
  • nginx:[emerg]bind()to0.0.0.0:80failed(98:Addressalreadyinuse)
  • nginx:[emerg]bind()to0.0.0.0:80failed(98:Addressalreadyinuse)
  • nginx:[emerg]bind()to0.0.0.0:80failed(98:Addressalreadyinuse)
  • 使用命令关闭占用80端口的程序
    sudo fuser -k 80/tcp

    安装成功验证

    Nginx 的参数包括:
    可以这样使用 /usr/local/nginx/sbin/nginx -参数

    -c <path_to_config>:使用指定的配置文件而不是 conf 目录下的 nginx.conf 。

    -t:测试配置文件是否正确,在运行时需要重新加载配置的时候,此命令非常重要,用来检测所修改的配置文件是否有语法错误。

    -v:显示 nginx 版本号。

    -V:显示 nginx 的版本号以及编译环境信息以及编译时的参数。

    copy [daydayup@bogonsbin]$sudo/usr/local/nginx/sbin/nginx-v

  • nginxversion:nginx/1.10.2
  • [daydayup@bogonsbin]$sudo/usr/local/nginx/sbin/nginx-t
  • nginx:theconfigurationfile/usr/local/nginx//conf/nginx.confsyntaxisok
  • nginx:configurationfile/usr/local/nginx//conf/nginx.conftestissuccessful
  • (编辑:安卓应用网)

    【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

      推荐文章
        热点阅读