在 Godaddy.com 上的 VPS 上开始反应

问题描述 投票:0回答:1

我已通过 ssh 进入我的 VPS,并使用

npx create-react-app test
在服务器上创建了初始 React 应用程序。然后我运行命令
npm start

然后我使用另一个也是 ssh 的终端,卷曲到

curl   http://localhost:3000
并收到正确的响应。

然后我关闭具有

npm start
的初始服务器。然后我重做
curl   http://localhost:3000
,但无法连接。难道curl不应该成功吗?我以为VPS会无限期地运行,因为它是一个服务器?关闭 ssh 连接后如何让该服务器继续运行?

reactjs ssh server vps
1个回答
0
投票

当您运行

npm start
时,它会启动一个为您的 React 应用程序提供服务的开发服务器进程。

要在断开 SSH 会话连接后仍保持服务器运行,您可以使用一些进程管理器,例如

pm2
forever
screen

但是使用

nginx
在 VPS 服务器上运行您的项目是个好主意。 请参阅此链接。 [https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-22-04][1]

© www.soinside.com 2019 - 2024. All rights reserved.