Last active
December 6, 2018 18:39
-
-
Save strickc/9f59702d4fc47ef18ee45316448d73e2 to your computer and use it in GitHub Desktop.
Bash script for AWS lightsail bitnami nodejs environment quick start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Create express app and configure apache httpd server | |
# creates sample-application in current directory (where the script is run from) | |
# To use run following commands from lightsail ssh session prompt: | |
# > git clone https://gist.github.com/strickc/9f59702d4fc47ef18ee45316448d73e2 quickstart | |
# > cd quickstart && ./lightsail-nodejs-quickstart.sh | |
# stop script on error | |
set -e | |
# https://docs.bitnami.com/aws/infrastructure/nodejs/get-started/get-started/ | |
echo Installing express and express-generator npm packages | |
sudo npm -g install express | |
sudo npm -g install express-generator | |
echo Generating sample-application express server | |
express sample-application | |
cd sample-application | |
APP_FOLDER=$( pwd ) | |
echo "Express server app created at $APP_FOLDER" | |
npm install | |
# Configure apache to forward to the express app port | |
# https://docs.bitnami.com/aws/infrastructure/nodejs/administration/create-custom-application-nodejs/ | |
cd $APP_FOLDER | |
sudo mkdir -p conf | |
# make htdocs symlink to public folder | |
ln -s public htdocs | |
echo "Include \"$APP_FOLDER/conf/httpd-app.conf\"" > conf/httpd-prefix.conf | |
echo 'ProxyPass / http://127.0.0.1:3000/ | |
ProxyPassReverse / http://127.0.0.1:3000/' > conf/httpd-app.conf | |
# edit apache configuration to include the app | |
echo "Include \"$APP_FOLDER/conf/httpd-prefix.conf\"" > /opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf | |
# restart apache | |
echo "Restarting apache httpd: sudo /opt/bitnami/ctlscript.sh restart apache" | |
sudo /opt/bitnami/ctlscript.sh restart apache | |
echo Starting express app with npm start. Press ctrl-c to stop . . . | |
echo App can also be started in background with forever start ./bin/www from the app directory | |
npm start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment