本文以Ubantu18.08为例:
首先进入虚拟机中升级apt-get:
apt-get update

nginx进行安装:
apt install nginx

使用命令查看nginx是否启动:
systemctl status nginx

nginx已经启动,可以到前端页面去访问是否真的已经启动,nginx已经提供了默认的页面。

对nginx配置文件进行配置:

对新建的self_dgw.conf文件进行简单编辑配置:
server {
listen 81;
location / {
root /home/;
}
}

使用命令检查上述的配置文件是否有错误:
nginx -t

配置文件写完后不需要重启nginx服务,只需要reload加载一下即可:
nginx -s reload

此时去访问81端口,服务已经启动:

此时forbidden是因为配置文件中写的路径/hom/下并没有文件,新建一个index.html文件进行测试:
<html>
<body>
<h1>hello world</h1>
</body>
</html>


上述文件保存后,此时不需要改动任何配置,直接到页面进行刷新即可:

查看nginx启动的进程:
ps -ef | grep nginx

关闭nginx服务:
nginx -s stop

优雅关闭nginx服务(推荐使用):
nginx -s quit

开启nginx服务:
systemctl start nginx

查看nginx状态:
systemctl status nginx

配置开机重启:
systemctl enable nginx

查看nginx版本:




![[附源码]计算机毕业设计基于springboot的小区宠物管理系统](https://img-blog.csdnimg.cn/5fd465a2ba824d229b3123c84c3aa17d.png)















