Centos7安装nginx

下载nginx

官网下载:http://nginx.org/ 选择最新 stable稳定版本就可以
这里写图片描述
选择稳定版本后,点击进去选择下载,下图左边是linux版本,右边是windows版本,我们下载linux版本
这里写图片描述

解压和编译安装

把文件上传在服务器中,我是上传在 /home/nginx 目录下
解压命令:tar -zvxf nginx-1.14.0.tar.gz
解压成功后:cd nginx-1.14.0

编译命令:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-file-aio --with-http_realip_module

如果是新环境,编译安装之前需要准备一些软件支持,编译过程中出现的一些错误和解决方式:

1.(./configure: error: C compiler cc is not found)
解决: yum install -y gcc gcc-c++

2../configure: error: the HTTP rewrite module requires the PCRE library
解决:yum -y install pcre-devel

3../configure: error: the HTTP gzip module requires the zlib library
解决:yum install -y zlib-devel

4../configure: error: the ssl module require the openssl library
解决:yum -y install openssl openssl-devel

安装命令:
make && make install

nginx运行、停止、重启

前往nginx安装目录:cd /usr/local/nginx
启动nginx:./sbin/nginx
编辑conf/nginx.conf之后,可以不用停止nginx直接重新加载就可以:./sbin/nginx -s reload
停止nginx:./sbin/nginx -s stop

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值