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

Centos7离线安装Nginx亲测版

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

Centos7离线安装Nginx亲测版

Centos7 Nginx编译包制作

找一台可连接互联网的虚拟机来制作编译好的Nginx包,具体操作如下

1、准备一台虚拟机(可访问互联网) 2、安装所需插件
$ yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel gcc-c++ libtool
3、准备nginx包 3.1、下载

通过网页下载,然后上传到Centos7系统的/opt目录下

或者,直接在Centos7系统下接命令下载到/opt目录下

$ cd /opt
$ wget http://nginx.org/download/nginx-1.14.0.tar.gz
3.2 解压

解压 nginx-1.14.0.tar.gz,并重命名为 nginx

$ cd /opt
$ tar zxf nginx-1.14.0.tar.gz
3.3 重命名
$ cd /opt
$ mv nginx-1.14.0 nginx
4、配置nginx
$ cd /opt/nginx
$ ./configure --prefix=/usr/local/nginx  --conf-path=/usr/local/nginx/conf/nginx.conf  --error-log-path=/usr/local/nginx/log/error.log --http-log-path=/usr/local/nginx/log/access.log

注:此处配置Nginx安装目录为 /usr/local/nginx,将来安装时,会在/usr/local/下生成nginx目录。

5、编译Nginx
$ cd /opt/nginx
$ make
6、打包Nginx
$ cd /opt
$ tar cvzf nginx.hasmake.1.14.0.tar.gz nginx

打包后,会在/opt 目录下生成一个 nginx.hasmake.1.14.0.tar.gz 包

Centos7 Nginx离线安装

上传包

应用 nginx.hasmake.1.14.0.tar.gz 已编译好的包,上传到对应的Centos7系统上,比如此处放到 /opt 目录下,则安装很简单

$ cd /opt
$ tar zxf nginx.hasmake.1.14.0.tar.gz	#解压后得到 nginx 目录
$ cd nginx								#进入 nginx 目录
$ make install							#安装

解压

安装完成后,将会在 /usr/local 目录下,生成一个 nginx 目录。如下

$ ll /usr/local/nginx
drwxr-xr-x. 2 root root 4096 11月 10 14:22 conf
drwxr-xr-x. 2 root root   38 11月 10 14:22 html
drwxr-xr-x. 2 root root    6 11月 10 14:22 log
drwxr-xr-x. 2 root root    6 11月 10 14:22 logs
drwxr-xr-x. 2 root root   18 11月 10 14:22 sbin

nginx 配置文件测试

$ /usr/local/nginx/sbin/nginx -t 

nginx 启动

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

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

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