linux centos nginx,Linux centos7环境下Nginx安装教程

Linux centos7环境下安装Nginx的步骤详解

1、 首先到Nginx官网下载

下载好后会见到类似下面的一份文件

7d69f87010c48e5ea48f1ce2f47a901d.gif

创建nginx-src目录并且去到nginx-src目录里运行如下命令即可:

mkdir nginx-src && cd nginx-src

当然也可以在Linux底下运行以下命令进行下载Nginx安装包

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

7d69f87010c48e5ea48f1ce2f47a901d.gif

2、解压nginx-1.5.9.tar.gz文件

tar -zxvf nginx-1.5.9.tar.gz

7d69f87010c48e5ea48f1ce2f47a901d.gif

3、删除安装包文件命令

rm -f nginx-1.5.9.tar.gz

7d69f87010c48e5ea48f1ce2f47a901d.gif

4、配置安装运行命令

cd nginx-1.5.9/ ./configure --prefix=/usr/local/nginx

7d69f87010c48e5ea48f1ce2f47a901d.gif

也许是提示缺包:

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

安装pcre-devel解决问题(需要有网络下运行并且是超级管理员身份)

yum -y install pcre-devel yum -y install openssl openssl-devel

7d69f87010c48e5ea48f1ce2f47a901d.gif

要切换为root超级管理员身份: su

2352.html

2017317112930126.jpg?2017217112943

7d69f87010c48e5ea48f1ce2f47a901d.gif

现在进行重新配置

./configure --prefix=/usr/local/nginx

如果重新配置也不成功这时需要安装gcc

yum Cy install gcc

7d69f87010c48e5ea48f1ce2f47a901d.gif

安装好gcc之后再次进行配置

7d69f87010c48e5ea48f1ce2f47a901d.gif

5、编译命令

Make

7d69f87010c48e5ea48f1ce2f47a901d.gif

6、安装命令

make install

7d69f87010c48e5ea48f1ce2f47a901d.gif

7、安装完毕,启动nginx

cd /usr/local/nginx/sbin

./nginx

7d69f87010c48e5ea48f1ce2f47a901d.gif

如果启动不成功可能是防火墙问题导致

这时需要关闭防火墙

systemctl stop firewalld.service

7d69f87010c48e5ea48f1ce2f47a901d.gif

8、访问nginx

http://IP地址

7d69f87010c48e5ea48f1ce2f47a901d.gif

9、如果要精简一下配置文件

重新加载配置文件

运行命令:nginx -s reload

到这里博主我就成功的在Linux Centos7下安装了Nginx服务器

并且已经成功的在浏览器上通过IP地址访问到nginx。

感谢各位朋友对我的支持! 非常感谢大家。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支Fatmouse

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值