说明:本教程针对内网环境(没有互联网环境)安装nginx
安装前测试,nginx未安装时,无法访问
curl http://localhost:80/
第一步:请参考教程 本地yum源安装,教程连接如下
https://note.youdao.com/s/EvVBTG0D
或者
https://blog.csdn.net/qq_29062045/article/details/128163684
第二步:下载nginx的tar包《nginx-1.22.1.tar.gz》
官网下载地址:
http://nginx.org/en/download.html
#创建一个文件夹
cd /usr/local && mkdir nginx
《nginx-1.22.1.tar.gz》上传到服务器 /usr/local/nginx 目录
第三步: 解压nginx包
cd /usr/local/nginx && tar -zxvf nginx-1.22.1.tar.gz
第四步: 安装nginx依赖(依赖第一步:本地yum源安装 务必安装成功)
#一键安装 四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
第五步: 安装nginx
#进入nginx目录
cd /usr/local/nginx/nginx-1.22.1
#执行命令 考虑到后续安装ssl证书 添加两个模块
./configure --with-http_stub_status_module --with-http_ssl_module
#执行make命令
make
#执行make install命令
make install
第五步: 启动nginx,测试
#启动nginx
cd /usr/local/nginx/sbin && ./nginx
#重启
cd /usr/local/nginx/sbin && ./nginx -s reload
测试访问:
curl http://localhost:80/
返回 nginx默认欢迎页,至此,nginx安装完成
具体nginx代理配置,请进入
cd /usr/local/nginx/conf && vim nginx.conf
注意:关于 nginx代理教程,请另行查阅资料。
nginx下载官网说明,如下图