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
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

eijiyey

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值