nginx 配置详解linux_linuxnginx搭建步骤

后端 (6) 2024-04-04 21:12

Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说nginx 配置详解linux_linuxnginx搭建步骤,希望能够帮助你!!!。
Linux系统下安装配置 Nginx 超详细图文教程

Linux系统下安装配置 Nginx 详细教程介绍

一、下载 Nginx 安装包

打开Nginx官网 :http://nginx.org/en/download.html
然后我们找到一个版本,把鼠标移动到上面,右键 - 复制链接地址

nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第1张
我们使用 wget 命令把Nginx安装包下载到/usr/local/目录中


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第2张
注意:
如果我们机子中没有安装 wget 需要先安装一下


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第3张
下载好包之后,我们解压安装包


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第4张

二、安装 Nginx 相关依赖

安装相关依赖文件


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第5张
安装好之后,进入nginx目录


执行配置脚本


如果遇到报错“https://blog.csdn.net/sigusoft_42716761/article/details/configure: error: C compiler cc is not found”,如下图

nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第6张
解决办法:


编译安装


三、启动 Nginx

注意:
启动前要查看端口是否放行,或者是防火墙是否关闭,否则无法访问

查看已放行的端口


放行8080端口,并重载防火墙


(这里nginx默认端口号是80,我们就放行80端口)

或者直接关闭防火墙

临时关闭


永久关闭


1.设置nginx开机自启动


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第7张
2. 启动 nginx


重载、停止 或 杀掉Nginx


3. 查询 ngin 是否启动


4. 访问 nginx页面

在浏览器中输入 ip + 端口号访问(端口默认80)

这样就算安装成功了

nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第8张

四、修改配置

1.修改端口和默认访问页面


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第9张
2.修改页面内容


nginx 配置详解linux_linuxnginx搭建步骤_https://bianchenghao6.com/blog_后端_第10张

今天的分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。