centos 安装 nginx

这里写目录标题

1. 写在前面

centos 安装nginx总共有3种方式 源码安装,yum源下载安装,docker镜像安装。接下来我就依次讲解下几种方式的安装

2. 源码安装

首先访问 nginx 的官网 nginx的官网,点击download连接
在这里插入图片描述

照到对应的型号和版本
在这里插入图片描述
输入shell命令

wget https://nginx.org/download/nginx-1.16.1.tar.gz

下载完成后就会得到一个Nginx的压缩包
在这里插入图片描述
接下来执行解压操作:

tar -zxvf  nginx-1.16.1.tar.gz 

进入解压好的文件夹,执行编译命令

 ./configure  

用这个命令容易报如下错误
在这里插入图片描述
其原因是你系统没有pcre包,输入如下命令可解决这个问题

yum -y install pcre-devel

还会出现如下问题

./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

其原因是你的系统内没有openssl相关的包,输入如下内容可以解决这个问题

yum -y install openssl openssl-devel

在这里插入图片描述
如图这样就执行完成了
再执行 make && make install

make && make install

在这里插入图片描述
当执行到这里之后说明nginx 已经安装成功了,关于configure 相关的配置请参照:nginx configure 相关的参数,在默认的情况下它是安装到 /usr/local 下面的,如图:
在这里插入图片描述
进入 nginx 下面的sbin

cd nginx/sbin

启动 nginx

./nginx

查看最终的效果
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值