Skip to content

Instantly share code, notes, and snippets.

@simkimsia
Last active December 11, 2015 02:08
Show Gist options
  • Select an option

  • Save simkimsia/4528222 to your computer and use it in GitHub Desktop.

Select an option

Save simkimsia/4528222 to your computer and use it in GitHub Desktop.
A simple bash script to create two instances for your webapp in nginx. The first is stage.webapp.com. The second is webapp.com. Usually put in /var/virtual
#!/bin/bash
###
#
# Copyright (c) 2013 KimSia Sim
#
# Ubuntu 12.10 based make directories in /var/virtual for webapp.com
# Run this by executing the following from a fresh install of Ubuntu 12.10 server:
#
# bash -c "$(curl -fsSL https://raw.github.com/gist/4528222)" <webapp.com>
#
# Be sure to replace <webapp.com> with your intended webapp name.
# Also, run this as www-data, unless you enjoy failing.
#
# Its handy to install 'screen' if you want to ensure your remote connection to
# a server doesn't disrupt the installation process. If you want to do this, just
# do the following before running the main bash command:
#
# apt-get install screen -y
# screen
#
# To recover your session if you are disconnected, ssh to your server as root again,
# and type:
#
# screen -x
#
# Dependencies:
# - curl
#
# Todo:
# - SSL Configuration
#
###
EXPECTEDARGS=0
if [ $# -ne $EXPECTEDARGS -o "x$0" == "x" -o $0 == "bash" ]; then
echo "Usage:"
echo " Parameter 1: your webapp.com name"
exit 1
fi
WEBAPP=$0
export DEBIAN_FRONTEND=noninteractive
########################################
## creating the directories
########################################
mkdir /var/virtual/$WEBAPP
mkdir /var/virtual/stage.$WEBAPP
########################################
## creating the usual config and ugc folders
########################################
mkdir /var/virtual/$WEBAPP/config
mkdir /var/virtual/$WEBAPP/uploads
mkdir /var/virtual/stage.$WEBAPP/config
mkdir /var/virtual/stage.$WEBAPP/uploads
########################################
## setting the permissions
########################################
chmod 775 /var/virtual/$WEBAPP
chmod 775 /var/virtual/stage.$WEBAPP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment