栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

nginx安装(linux版)

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

nginx安装(linux版)

nginx安装(linux版)

一、进入官网http://nginx.org/en/download.html,找到最新linux版本,右键复制链接http://nginx.org/download/nginx-1.21.6.tar.gz

二、下载到/usr/local/src

[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://nginx.org/download/nginx-1.21.6.tar.gz


三、解压安装包

[root@localhost src]# ls
nginx-1.21.6.tar.gz
[root@localhost src]# tar -zxvf nginx-1.21.6.tar.gz

四、进入nginx解压目录进行配置

[root@localhost src]# cd ./nginx-1.21.6
[root@localhost nginx-1.21.6]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src
[root@localhost nginx-1.21.6]# ./configure --prefix=/usr/local/nginx

配置时报错,原因是缺少PCRE库

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

解决方案:yum安装pcre-devel

[root@localhost nginx-1.21.6]# yum install pcre-devel

输入y进行确认

重新进行配置

[root@localhost nginx-1.21.6]# ./configure --prefix=/usr/local/nginx --with-pcre

发现还是报错,缺少zlib库

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

[root@localhost nginx-1.21.6]# 
Socket error Event: 32 Error: 10053.
Connection closing...Socket close.

Connection closed by foreign host.

Disconnected from remote host(远程虚拟机) at 20:27:09.

Type `help' to learn how to use Xshell prompt.
[D:~]$ 

解决方案:yum安装zlib-devel

[root@localhost nginx-1.21.6]# yum install zlib-devel

输入y进行确认

进入src目录下载zlib源码包并解压出来

[root@localhost nginx-1.21.6]# cd ..
[root@localhost src]# wget http://www.zlib.net/zlib-1.2.12.tar.gz
[root@localhost src]# tar -zxvf zlib-1.2.12.tar.gz

重新进行配置

[root@localhost nginx-1.21.6]#  ./configure --prefix=/usr/local/nginx

五、编译安装

[root@localhost nginx-1.21.6]# make
[root@localhost nginx-1.21.6]# make install

查看有没有这个nginx目录

[root@localhost nginx-1.21.6]# ls /usr/local/nginx/
conf  html  logs  sbin
[root@localhost nginx-1.21.6]# 

六、启动

[root@localhost nginx-1.21.6]#  /usr/local/nginx/sbin/nginx
[root@localhost init.d]# netstat -anput | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      21864/nginx: master 

关闭防火墙,在浏览器上输入ip进行验证

[root@localhost ~]# systemctl stop firewalld

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/871556.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号