【问题标题】:MERN stack app deployment to AWS EC2 instanceMERN 堆栈应用程序部署到 AWS EC2 实例
【发布时间】:2020-08-19 05:16:58
【问题描述】:

您好,我正在尝试设置我的 aws 实例并部署我的 mern 应用程序(它不是静态应用程序),但我发现很多人在做不同的事情,这让我有点困惑,谁能解释一下我必须经历的过程才​​能使用 aws 部署功能性的 mern 应用程序?无需赘述,我只需要有人向我解释一下基础知识即可。

【问题讨论】:

    标签: amazon-web-services amazon-ec2 mern


    【解决方案1】:

    使用 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
    

    【讨论】:

    • 感谢您的回答,只是一个简单的问题,您推荐使用 windows server 还是 ubuntu 实例?
    • 这完全基于个人选择,但我总是使用 ubuntu ... 没有使用 windows 的经验,所以不能回答
    猜你喜欢
    • 1970-01-01
    • 2014-09-11
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-18
    • 2019-04-20
    • 1970-01-01
    相关资源
    最近更新 更多