CentOS下Nginx部署React静态应用
查看CentOS版本:
cat /etc/redhat-release
安装nginx:
yum install nginx
查看nginx版本:
nginx -v
启动nginx:
systemctl start nginx
nginx默认发布目录:
cd /usr/share/nginx/
由于是单页应用虚拟路由的原因,需要将nginx的所有请求都转发到index.html页面,所以需要修改配置文件:
server {listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ~* html {
rewrite .* /index.html break;
root /usr/share/nginx/html/;
}
error_page 404 /404.html;
location = /index.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
以上是 CentOS下Nginx部署React静态应用 的全部内容, 来源链接: utcz.com/z/383208.html