1. 安装Nginx
日志文件
/var/log/ngxin
error.log access.log
配置目录
/etc/nginx/nginx.conf
修改 /etc/nginx/sites-enabled/defualt 文件.
配置文件
default
server {
listen 80 default_server;
listen [::]:80 default_server;
# vue项目打包后的文件夹
# 上传到服务器的位置
root /home/graduation/www/h5;
index index.html;
server_name _;
location / {
# First attempt to serve request as file, then
try_files $uri $uri/ @router;
index index.html;
}
# 路由给Vue
location @router{
rewrite ^.*$ /index.html last;
}
}
常用命令
更新了build文件或者配置文件 nginx -s reload
重启 service nginx restart
查看被占用端口lsof -i:80
or netstat -lnp | grep 80
终止进程 kill PID号
2.安装nodejs和npm
sudo apt-get nodejs
可用以下命令查看安装
3.阿里云控制台打开端口80
4.nginx问题
绑定端口失败 nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
netstat -lnp | grep 80
kill [进程号]
service nginx start