liunx安装nginx ---- 不通过 yum

小咪咪 2022-05-22 04:30 301阅读 0赞

1:首先我们需要下载nginx:

  1. wget http://nginx.org/download/nginx-1.14.0.tar.gz

nginx-1.14.0.tar.gz:对应的版本号,比如现在最新的是1.14.0
这里写图片描述

2:下载好了之后我们就会发现有一个压缩包:进行解压

  1. tar -zxvf nginx-1.14.0.tar.gz

这里写图片描述

3:解压到这一步我觉得我们需要配置一点东西,就是关于nginx安全方面的,隐藏名称,这里我们可以参考这篇博客:
https://blog.csdn.net/yuanzhenwei521/article/details/78819482

4:然后进行configure 命令:(在nginx-1.14.0目录下)

  1. [******** nginx-1.14.0]# ./configure --prefix=/usr/local/nginx

应该会报错:

  1. ./configure: error: the HTTP rewrite module requires the PCRE library.
  2. You can either disable the module by using --without-http_rewrite_module
  3. option, or install the PCRE library into the system, or build the PCRE library
  4. statically from the source with nginx by using --with-pcre=<path> option.
  5. 解决方法:
  6. [******** nginx-1.14.0]# yum -y install pcre-devel
  7. ./configure: error: the HTTP gzip module requires the zlib library.
  8. You can either disable the module by using --without-http_gzip_module
  9. option, or install the zlib library into the system, or build the zlib library
  10. statically from the source with nginx by using --with-zlib=<path> option.
  11. 解决方法:
  12. [******** nginx-1.14.0]# yum install -y zlib-devel

最后大概是这个样子:
这里写图片描述

5:进行编译:

  1. [******** nginx-1.14.0]# make && make install

编译好之后大概是这样:
这里写图片描述

6:安装位置在第4步截图会有显示
我的安装目录在:/usr/local/nginx

7:修改 nginx.conf文件

8:

  1. 检查语法:sbin/nginx -t
  2. nginx端口:ps -ef|grep nginx
  3. 启动:sbin/nginx
  4. 停止:sbin/nginx -s quit/stop

9:
如果出现访问不了的话,但是nginx是正常启动中,可以通过查看端口进行确认。这时你可能就需要查看防火墙,或者检查下安全组,关于6379端口是否放行了

其实感觉这样安装的话只有一个好处,就是能够在编译前进行版本号,所用的nginx这个中间件进行隐藏外,其余方面到没有觉得有什么,
如果对安全方面没有太高的要求的话,或者说我就是用的nginx 1.12.1 这个版本,你看见了就看见了,我不在乎,那么就可以通过yum命令进行安装,会简单很多倍:https://blog.csdn.net/qq_38637558/article/details/80518199

发表评论

表情:
评论列表 (有 0 条评论,301人围观)

还没有评论,来说两句吧...

相关阅读