一、打包好你的react本地项目,dist中具备打包好的文件html
二、使用shell等工具登陆你的linux服务器react
三、安装nginx,网上教程一大堆linux
四、进入/usr/local/nginx/conf/nginx.confnginx
五、vi nginx.confshell
server {
listen 8080;
# server_name your.domain.com;
root /home/root/react-demo;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
复制代码
六、将本地react项目中的dist里的文件夹上传至/home/root/react-demo中服务器
七、进入/usr/local/nginx/sbin下,输入命令./nginx -t(重启nginx),若是未开启的话能够使用开启命令/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confdom
八、访问你的ip+端口号8080,就能够打开网站了工具
九、后续的更新代码只须要将/home/root/react-demo中的旧代码删掉,再将打包好的代码上传到/home/root/react-demo中网站