用nginx部署前端项目全过程
1.前端的默认首页使用 index.html在部署的时候会用到该页面。2.将打包好的前端页面dist文件夹放在服务器(centos 或 ubuntu) 指定路径 ,如 /home/project/shopping, 项目包含js,css和html等3.安装nginx12sudosurootapt-getinstallnginx查看nginx是否安装成功1nginx -vnginx安装成功后的位置如下/usr/sbin/nginx主程序/etc/nginx配置文件所在路径/usr/share/nginx静态文件所在路径/var/log/nginx日志文件所在路径4.修改配置将项目的根目录所在路径作为 location / 的 root 对应的值 index.html页面作为index 的值如下配置123456789101112131415161718192021222324252627282930#user nobody;worker_processes 1;events {worker_connections 1024;}http {include mime.types;default_type application/octet-stream;sendfile on;#tcp_nopush on;#gzip on;server {listen 8080;server_name localhost;location / {root/home/project/shoping;index index.html index.htm;}error_page 500 502 503 504/50x.html;location /50x.html {root html;}}}5.修改完毕后保证配置无误重新启动nginx , 可用nginx -t 检验nginx配置是否正确 , 配置无误后使用 nginx -s reload 命令重新加载修改的配置。123nginx -tnginx -s reloadservice nginx restart启动成功后访问: http://116.62.146.90:8080/ 此处要修改为自己机器的ip地址。总结以上为个人经验希望能给大家一个参考