react 項目部署啟動的方法

一、使用serve服務(wù)啟動

1,安裝serve

npm install -g serve

2.進入項目目錄,啟動

serve -s -d -n -l 5000 (5000是指定的端口號)

需要切換到項目目錄下執(zhí)行以上命令:

執(zhí)行結(jié)果:

--help?可以查看命令幫助


二、使用nginx作為服務(wù)啟動

1.安裝nginx(見連接)

nginx安裝


2.配置

vim? /etc/nginx/nginx.conf

加入如下配置:

server {

? ? ? ? ? ? ? ? listen 443;

? ? ? ? ? ? ? ? server_name? xx.xxx.com;

? ? ? ? ? ? ? ? root /var/www/web-cloud;

? ? ? ? ? ? ? ? ssl_certificate "/xxx.pem";

? ? ? ? ? ? ? ?ssl_certificate_key "/xxx.key";

? ? ? ? ? ? ? ?ssl_protocols? ? ? TLSv1 TLSv1.1 TLSv1.2;

? ? ? ? ?????ssl_ciphers? ? ? ? HIGH:!aNULL:!MD5;

? ? ? ? ? ? ? ? index index.html;

? ? ? ? ? ? ? ? location ~ ^/favicon\.ico$ {

? ? ? ? ? ? ? ? ? ? ? ? root /var/www/web-cloud;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? location / {

? ? ? ? ? ? ? ? ? ? ? ? try_files $uri $uri/ @fallback;

? ? ? ? ? ? ? ? ? ? ? ? index index.html;

? ? ? ? ? ? ? ? ? ? ? ? proxy_set_header? Host? ? ? ? ? ? $host;

? ? ? ? ? ? ? ? ? ? ? ? proxy_set_header? X-Real-IP? ? ? ? $remote_addr;

? ? ? ? ? ? ? ? ? ? ? ? proxy_set_header? X-Forwarded-For? $proxy_add_x_forwarded_for;

? ? ? ? ? ? ? ? ? ? ? ? proxy_set_header? X-Forwarded-Proto? $scheme;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? location @fallback {

? ? ? ? ? ? ? ? ? ? ? ? rewrite ^.*$ /index.html break;

? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? access_log? /opt/local/access.log? main;

? ? ? ? }

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容