Linux /centos7下源码安装Nginx

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/Rainday666/article/details/102575248

1、下载或上传nginx安装包
我这边使用wget命令直接在centos7上下载,上传安装包的可以忽略直接下一步
-bash: wget: 未找到命令

2、提示未找到wget命令,安装wget命令
yum install -y wget

3、安装完成wget命令后再次执行第一步操作下载nginx
wget http://nginx.org/download/nginx-1.16.1.tar.gz

4、解压软件包,ls命令查看nginx目录,并进入nginx目录
tar zxvf nginx-1.16.1.tar.gz
5、进入nginx目录后预编译,提示错误,缺少C编译器
./configure
提示:./configure: error: C compiler cc is not found
6、安装c编译器
yum install -y gcc-c++

7 、c编译器安装完成,再次进行预编译,错误提示缺少依赖库pcre
./configure
提示
./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
8、安装依赖库pcre
yum install -y pcre-devel
./configure

9、pcre库组件安装完成,再次进行预编译,错误提示缺少依赖库zlib
./configure
./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.
10、安装依赖库zlib
yum install -y zlib-devel
11、依赖库zlib安装完成,再次进行预编译
./configure
12、预编译完成后,ls查看目录文件,会多出“Makefile”目录

13、使用make命令编译,编译过程内容过多,中间内容不在贴出
make
14、编译完成后,安装nginx
make install
15、 使用网页访问nginx(先临时关闭防火墙,查看防火墙已关闭)
service firewalld stop
16访问nginx
http://47.102.153.86/

猜你喜欢

转载自blog.csdn.net/Rainday666/article/details/102575248