【发布时间】:2020-08-19 05:16:58
【问题描述】:
您好,我正在尝试设置我的 aws 实例并部署我的 mern 应用程序(它不是静态应用程序),但我发现很多人在做不同的事情,这让我有点困惑,谁能解释一下我必须经历的过程才能使用 aws 部署功能性的 mern 应用程序?无需赘述,我只需要有人向我解释一下基础知识即可。
【问题讨论】:
标签: amazon-web-services amazon-ec2 mern
您好,我正在尝试设置我的 aws 实例并部署我的 mern 应用程序(它不是静态应用程序),但我发现很多人在做不同的事情,这让我有点困惑,谁能解释一下我必须经历的过程才能使用 aws 部署功能性的 mern 应用程序?无需赘述,我只需要有人向我解释一下基础知识即可。
【问题讨论】:
标签: amazon-web-services amazon-ec2 mern
使用 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
【讨论】: