Go to https://lightsail.aws.amazon.com/ls/webapp/home/instances
Click “Create instance” button on top right corner
Create Instance:
Instance Location: us-east-1a
Platform: Linux/Unix
Blueprint: Apps + OS –> Node.js
Instance Plan: select least expensive
Identify your instance: <your-instance-name>
Create Instance
SSH into the instance:
Host: Public IP
Port: 22
Username: Bitnami
Key: <aws-key>
Clone git repository (this will also create the parent directory):
git clone <git-clone-link>
cd ~/<directory-name>
Install npm packages:
sudo npm install
Start the server:
sudo npm install pm2 -g
pm2 start dist/server.js --log-date-format 'DD-MM HH:mm:ss.SSS'
git checkout <branch name>
git pull
if you get this error: error: Your local changes to the following files would be overwritten by checkout: Please commit your changes or stash them before you switch branches:
git checkout -- .
for use with process.env.param
sudo nano /opt/bitnami/nodejs/bin/node
example:
#!/bin/sh
export REGION="us-east-1"
export ACCESS_KEY_ID="AAAAAAAAAAAAAAAAAAAA"
export SECRET_ACCESS_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
. /opt/bitnami/scripts/setenv.sh
exec /opt/bitnami/nodejs/bin/.node.bin "$@"
- Note: To save: Exit (ctrl+X), Yes (y), Enter
Change the apache settings file:
cd /opt/bitnami/apache2/conf/bitnami
nano bitnami-apps-prefix.conf
Enter this text so that the apache settings file will look at 3000:
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
restart apache to make your changes count:
sudo /opt/bitnami/ctlscript.sh restart apache