MERN堆栈应用程序部署到AWS EC2实例

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

你好,我试图设置我的aws实例并部署我的mern应用程序(它不是静态应用程序),但是我发现有很多人在做不同的事情,这让我有些困惑,任何人都可以向我解释我必须经历一个具有aws的功能性部署mern应用程序的过程?无需赘述,我只需要有人向我解释基本知识即可。

amazon-web-services amazon-ec2 mern
1个回答
0
投票

使用NodeJS设置AWS服务器:

- Create instance.
- ssh into instance
- Git clone the repo
- Sudo apt-get update
- install npm
- npm install
- Add any env or required file that is in gitignore
- sudo ufw allow ssh
- sudo ufw allow 443/tcp
- sudo ufw allow 80/tcp

设置PM2并配置端口80

- $ sudo npm install pm2 -g
- $ pm2 start index.js
- $ pm2 stop index
- Open up your apps index.js file and change port 5000(default) to port 80
- Also need to upload and configure certificate files to use port 443 with https
- $ sudo apt-get install libcap2-bin
- $ sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
- $ pm2 start index
© www.soinside.com 2019 - 2024. All rights reserved.