1.官网下载linux版本nginx安装包,下载地址:http://nginx.org/en/download.html
2.安装包拖至安装目录,我用的目录是 /usr/local
3.解压安装包,命令:tar -zxvf tar -zxvf nginx-1.19.0.tar.gz
4.进入nginx解压目录:cd cd nginx-1.19.0
5.配置。命令 ./configure --prefix=/usr/local/nginx
此时遇到了报错,报错为:./configure: error: the HTTP rewrite module requires the PCRE library.
解决办法为:yum -y install pcre-devel
上步安装完成继续执行./configure --prefix=/usr/local/nginx ,又遇到错误:./configure: error: the HTTP gzip module requires the zlib library.
解决办法:yum install -y zlib-devel
上步完成后继续执行./configure --prefix=/usr/local/nginx,成功。
6.执行命令:make
7.执行命令:make install
8.进入 /usr/local/nginx/sbin 下,执行./nginx 启动nginx,之后访问ip的80端口,有欢迎页面就成功了