安装教程:https://blog.csdn.net/qq_42716761/article/details/126970218
一、查看 nginx 运行状态状态
ps -ef | grep nginx
二、查看配置文件 nginx.conf 路径
nginx -t
三、nginx启动(linux命令)
nginx
查询 nginx 是否启动
ps -ef | grep nginx
四、新增存放`部署项目`目录,把文件上传到服务器
五、配置nginx( /nginx/nginx.con文件 )
1、设置挂载静态web项目,自定义配置(如已有配置忽略)
http {
....# 挂载静态web项目,自定义配置include webSite-conf/*.conf;....
}
2、新增自定义配置文件夹(webSite-conf),在nginx目录同级(如已有配置忽略)
3、在 webSite-conf文件夹 中新增`部署项目`的配置文件( 如:xxxx.conf )
4、xxxx.conf 文件内容
server {#端口listen 9999; #访问域名(如果本机就使用`_`, 域名或别的ip请更换)server_name _; #项目放置的目录root xxxxx; index index.html index.htm index.php default.html default.htm default.php;# error_page 404 /404.html;location / {#vue-history模式下配置防止刷新404try_files $uri $uri/ /index.html;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {expires 30d;}location ~ .*\.(js|css)?$ {expires 12h;}location ~ /.well-known {allow all;}location ~ /\. {deny all;}access_log off;
}
5、重启nginx(linux命令)
nginx -s reload