在Elastic Beanstalk上,可以设置环境
option_settings:
- namespace: aws:elasticbeanstalk:container:nodejs:staticfiles
option_name: /public
value: /public
- option_name: NODE_ENV
value: production
并且还访问节点/ express中的变量,例如
console.log('Using production settings.');
app.set('connection', mysql.createConnection({
host: process.env.RDS_HOSTNAME,
user: process.env.RDS_USERNAME,
password: process.env.RDS_PASSWORD,
port: process.env.RDS_PORT}));
现在,如果我必须在EC2上做同样的事情(不使用Elastic Beanstalk)