找一台可连接互联网的虚拟机来制作编译好的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 包
- 上传包
应用 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
热门文章
- 1月13日 | Clash Verge每天更新18.2M/S免费节点订阅链接地址
- 芭比堂宠物医院体育大街(芭比堂宠物医院玉泉路总店)
- C语言实现随机抽签
- 动物疫苗市场开放(动物疫苗经销商)
- 11月6日 | Clash Verge每天更新21.9M/S免费节点订阅链接
- 12月1日 | Clash Verge每天更新18.5M/S免费节点订阅链接
- 兰州哪里卖宠物鸭的多(兰州哪里有卖鸭子活体的地方)
- 12月25日 | Clash Verge每天更新18.4M/S免费节点订阅链接地址
- 国考公务员2021年报名公告(2021年国考公务员报考公告)
- 11月5日 | Clash Verge每天更新18.7M/S免费节点订阅链接