Linux CentOs7下的Nginx安装与启动

Nginx安装详细教程

系统:centOS7

Nginx版本:1.14.1

本教程使用编译源码方式进行安装

 Nginx下载地址:

http://nginx.org/download/nginx-1.14.1.tar.gz

可以使用wget命令直接在nginx下载

wget http://nginx.org/download/nginx-1.14.1.tar.gz

Nginx安装:

事先在/usr/local创建nginx目录

进入目录下载nginx源码包:

cd /usr/local/nginx

wget http://nginx.org/download/nginx-1.14.1.tar.gz

解压:

tar -zxvf nginx-1.14.1.tar.gz

解压后:

进入目录开始安装:

#运行configure脚本 (可能会遇到缺少环境的问题,一会把可能出现的问题写在下面)
#在这之前可以先看看下面可能会遇到的问题 提前把这几个必要的包都安装好

./configure

#编译 (在nginx解压目录进行) /usr/local/nginx/nginx-1.14.1

make

#安装

make install

安装完成后,/usr/local/nginx会多出编译好的目录

 运行configure脚本可能会遇到的问题

(1)缺少 gcc-c++

[root@localhost nginx-1.14.1]# ./configure

checking for OS

 + Linux 3.10.0-862.el7.x86_64 x86_64

checking for C compiler ... not found 

./configure: error: C compiler cc is not found

解决办法:

安装gcc-c++

yum -y install gcc-c++

(2)缺少 pcre-devel 

./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.

解决办法:

安装 pcre-devel :

yum -y install pcre-devel

(3)缺少zlib-devel

./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.

解决办法:

安装zlib-devel

yum install -y zlib-devel

启动Nginx

#启动  nginx 命令路径 -c 配置文件路径
/usr/local/nginx/sbin/nginx  -c /usr/local/nginx/conf/nginx.conf

下面是启动成功的效果,nginx默认80端口

教程到这就结束了,有问题的地方希望大家多多指点~

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值