源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

Linux centos7环境下Nginx安装教程

  • 时间:2022-03-13 15:22 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:Linux centos7环境下Nginx安装教程
Linux centos7环境下安装Nginx的步骤详解 1、 首先到Nginx官网下载[url=http://xiazai.jb51.net/201703/yuanma/nginx(jb51.net).rar]Nginx安装包[/url] 下载好后会见到类似下面的一份文件 [img]http://files.jb51.net/file_images/article/201703/201703171127298.png[/img] 创建nginx-src目录并且去到nginx-src目录里运行如下命令即可:
mkdir nginx-src && cd nginx-src
当然也可以在Linux底下运行以下命令进行下载Nginx安装包
wget http://nginx.org/download/nginx-1.5.9.tar.gz
[img]http://files.jb51.net/file_images/article/201703/201703171127299.png[/img] 2、解压nginx-1.5.9.tar.gz文件
tar -zxvf nginx-1.5.9.tar.gz
[img]http://files.jb51.net/file_images/article/201703/2017031711272910.png[/img] 3、删除安装包文件命令
rm -f nginx-1.5.9.tar.gz
[img]http://files.jb51.net/file_images/article/201703/2017031711272911.png[/img] 4、配置安装运行命令
cd nginx-1.5.9/

./configure --prefix=/usr/local/nginx
[img]http://files.jb51.net/file_images/article/201703/2017031711272912.png[/img] 也许是[b]提示缺包:[/b] ./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. [b]安装pcre-devel解决问题[/b](需要有网络下运行并且是超级管理员身份)
yum -y install pcre-devel
yum -y install openssl openssl-devel

[img]http://files.jb51.net/file_images/article/201703/2017031711272913.png[/img] 要切换为root超级管理员身份: su [img]http://files.jb51.net/file_images/article/201703/2017317112930126.jpg?2017217112943[/img] [img]http://files.jb51.net/file_images/article/201703/2017031711272915.png[/img] 现在进行重新配置 ./configure --prefix=/usr/local/nginx 如果重新配置也不成功这时需要安装gcc
yum –y install gcc
[img]http://files.jb51.net/file_images/article/201703/2017031711272916.png[/img] 安装好gcc之后再次进行配置 [img]http://files.jb51.net/file_images/article/201703/2017031711272917.png[/img] 5、编译命令 Make [img]http://files.jb51.net/file_images/article/201703/2017031711272918.png[/img] 6、安装命令 make install [img]http://files.jb51.net/file_images/article/201703/2017031711272919.png[/img] 7、安装完毕,启动nginx cd /usr/local/nginx/sbin ./nginx [img]http://files.jb51.net/file_images/article/201703/2017031711273020.png[/img] 如果启动不成功可能是防火墙问题导致 这时需要关闭防火墙 systemctl stop firewalld.service [img]http://files.jb51.net/file_images/article/201703/2017031711273021.png[/img] 8、访问nginx http://IP地址 [img]http://files.jb51.net/file_images/article/201703/2017031711273022.png[/img] 9、如果要精简一下配置文件 重新加载配置文件 运行命令:nginx -s reload 到这里博主我就成功的在Linux Centos7下安装了Nginx服务器 并且已经成功的在浏览器上通过IP地址访问到nginx。 感谢各位朋友对我的支持! 非常感谢大家。 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部