一、打包好你的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中網站