CentOS下Nginx部署React靜態應用
阿新 • • 發佈:2017-07-20
ati tar pre include eas files 安裝nginx react oot
查看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_page500 502 503 504 /50x.html; location = /50x.html { } }
CentOS下Nginx部署React靜態應用