整理记录下学习整个瑞吉外卖项目,详细代码可在我的Gitee仓库瑞吉外卖实战克隆下载学习使用!
![![[Pasted image 20230311152143.png]]](https://img.pic99.top/cnyincai/202406/4f2b6036c1ec64.png)
![![[Pasted image 20230311154158.png]]](https://img.pic99.top/cnyincai/202406/f3c89b18d4c28.png)
apt-get install nginx,如图![![[Pasted image 20230311154908.png]]](https://img.pic99.top/cnyincai/202406/1cfdd9e89641a8.png)
apt install tree安装tree查看目录结构,命令cd /etc/nginx进入后查看,如图![![[Pasted image 20230311160021.png]]](https://img.pic99.top/cnyincai/202406/a623687b2cc4d0b.png)
命令nginx -v,如图![![[Pasted image 20230311160141.png]]](https://img.pic99.top/cnyincai/202406/f0d7471ce5a3.png)
命令nginx -t,如图![![[Pasted image 20230311160249.png]]](https://img.pic99.top/cnyincai/202406/7cfe0a2b9bb9608.png)
nginx或service nginx start,并用ps -ef|grep nginx查看进程,如图![![[Pasted image 20230311160902.png]]](https://img.pic99.top/cnyincai/202406/87dead658ac46c.png)
127.0.0.1如图启动成功nginx -s stop或者service nginx stop,关闭服务,查看进程后显示关闭![![[Pasted image 20230311161248.png]]](https://img.pic99.top/cnyincai/202406/6f6d2efc3c75198.png)
命令nginx -s reload,当Nginx启动后修改了配置文件后使用
![![[Pasted image 20230311165456.png]]](https://img.pic99.top/cnyincai/202406/ca8bd51953ed9ec.png)
![![[Pasted image 20230311193154.png]]](https://img.pic99.top/cnyincai/202406/20ca4cde8cb2ba0.png)
![![[Pasted image 20230311193336.png]]](https://img.pic99.top/cnyincai/202406/022436180589749.png)
![![[Pasted image 20230311165613.png]]](https://img.pic99.top/cnyincai/202406/4d33ecb5f892d8a.png)
server{
listen:80; #监听端口
server_name:localhost;#服务器名称
location/{#匹配客户端请求url
root html;#指定静态资源根目录
index index.html;#指定默认首页
}
}
![![[Pasted image 20230311193601.png]]](https://img.pic99.top/cnyincai/202406/3122a5908432a4b.png)
![![[Pasted image 20230311193522.png]]](https://img.pic99.top/cnyincai/202406/044cdeef260143c.png)
![![[Pasted image 20230311201317.png]]](https://img.pic99.top/cnyincai/202406/68c6ae7dbf555f5.png)
![![[Pasted image 20230311201426.png]]](https://img.pic99.top/cnyincai/202406/feb444a1a85e4c8.png)
![![[Pasted image 20230311201447.png]]](https://img.pic99.top/cnyincai/202406/538ed2e928c9b58.png)
![![[Pasted image 20230311201809.png]]](https://img.pic99.top/cnyincai/202406/2c8e9e70f884f2e.png)



/etc/nginx/nginx.conf,配置文件支持嵌套,/etc/nginx/nginx.conf文件里已经配置已经使用语句include /etc/nginx/sites-enabled/*; 如图![![[Pasted image 20230311195233.png]]](https://img.pic99.top/cnyincai/202406/a632599e5a8c569.png)
/etc/nginx/sites-enabled/文件夹下所有的文件,内容如图![![[Pasted image 20230311195401.png]]](https://img.pic99.top/cnyincai/202406/2d0871e84c499d7.png)
cd /etc/nginx/sites-enabled/sudo rm defaultcd /etc/nginx/sites-available/cp default my_config![![[Pasted image 20230311201228.png]]](https://img.pic99.top/cnyincai/202406/5f8f2d95bccdaaa.png)
ln -s /etc/nginx/sites-available/my_config /etc/nginx/sites-enabled/my_confgnginx -s reload