MERN 堆栈应用程序部署到 AWS EC2 实例
MERN stack app deployment to AWS EC2 instance
你好,我正在尝试设置我的 aws 实例并部署我的 mern 应用程序(它不是静态应用程序),但我发现很多人在做不同的事情,这让我有点困惑,任何人都可以向我解释我必须经历的过程才能使用 aws 部署功能性的 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
你好,我正在尝试设置我的 aws 实例并部署我的 mern 应用程序(它不是静态应用程序),但我发现很多人在做不同的事情,这让我有点困惑,任何人都可以向我解释我必须经历的过程才能使用 aws 部署功能性的 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