将MERN Stack App部署到AWS EC2(什么都没有发生)

时间:2018-11-17 20:50:52

标签: node.js amazon-web-services amazon-ec2 mern

因此,我最近尝试将Mern应用程序部署到AWS的EC2上。但是,在按照所有步骤进行设置之后,即使所有命令都能完美执行(甚至npm start等),URL也不会返回任何内容(aka拒绝连接)。

这是我的package.json文件:

前端:

{
"name": "ems-webapp",
"version": "0.1.0",
"private": true,
"dependencies": {
    "axios": "^0.18.0",
    "bootstrap": "^4.1.3",
    "dotenv": "^6.1.0",
    "jquery": "^3.3.1",
    "js-cookie": "^2.2.0",
    "lodash.uniqueid": "^4.0.1",
    "react": "^16.5.2",
    "react-bootstrap-table": "^4.3.1",
    "react-bootstrap-table-next": "^1.1.4",
    "react-cookie": "^3.0.4",
    "react-dom": "^16.5.2",
    "react-redux": "^5.0.7",
    "react-router": "^4.3.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "1.1.5",
    "react-strap": "0.0.1",
    "reactstrap": "^6.4.0",
    "redux": "^4.0.0",
    "redux-thunk": "^2.3.0",
    "webpack": "^3.11.0"
},
"scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
},
"description": "An Election Management System",
"main": "index.js",
"repository": {
    "type": "git",
    "url": "ems-webapp"
},
"author": "Sushrit Pasupuleti",
"license": "ISC",
"devDependencies": {}
}

后端:

{
"name": "election-management-system-webapp",
"version": "1.0.0",
"description": "An Election Management App",
"main": "index.js",
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack"
},
"author": "Sushrit Pasupuleti",
"license": "ISC",
"dependencies": {
    "axios": "^0.18.0",
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.18.3",
    "concurrently": "^4.0.1",
    "connect-mongo": "^2.0.1",
    "cookie-parser": "^1.4.3",
    "cookie-session": "^2.0.0-beta.3",
    "cors": "^2.8.4",
    "dotenv": "^6.1.0",
    "express": "^4.16.3",
    "express-session": "^1.15.6",
    "jsonwebtoken": "^8.3.0",
    "mongoose": "^5.2.16",
    "passport": "^0.4.0",
    "passport-google-oauth": "^1.0.0",
    "passport-google-oauth-jwt": "^0.2.3",
    "passport-google-oauth20": "^1.0.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0"
},
"devDependencies": {
    "webpack": "^4.25.1",
    "webpack-cli": "^3.1.2"
}
}

我首先进入客户端,npm安装所有内容,然后运行“ npm run build”,然后运行“ npm start”来运行客户端服务器。

然后在另一个我进入服务器的shell中,npm安装所有内容,然后运行“ node server.js”。 Shell中的所有输出均符合预期。

但是当我访问我的EC2实例的公共IP地址时,我什么都没看到,它拒绝连接。

此外,仅供参考,我的应用中所有带有url的都设置为localhost(3000和5000),我应该更改它还是其他?

感谢所有帮助。

1 个答案:

答案 0 :(得分:0)

鉴于您没有提到您的Web服务器配置,这可能是您的Web服务器(我假设为Nginx,因为它是MERN)未运行或未配置的可能原因之一。您可以向您展示/etc/nginx/sites-available/etc/nginx/sites-enabled的内容吗?