Skip to content

Instantly share code, notes, and snippets.

@andypotanin
Last active September 29, 2016 21:00
Show Gist options
  • Save andypotanin/7406289 to your computer and use it in GitHub Desktop.
Save andypotanin/7406289 to your computer and use it in GitHub Desktop.
Setup CentOs 6.3 on Google Compute Engine with Node.js, Git, SVN and other commons.
# Set variables in .bash_profile for convenience:
# GOOGLE_COMPUTE_PROJECT_NAME - e.g. "my-project"
#
# Run locally:
# sudo ssh-add ~/.ssh/google_compute_engine
# gcutil ssh $GOOGLE_COMPUTE_INSTANCE_NAME
# Cache project name
gcutil getproject --project=$GOOGLE_COMPUTE_PROJECT_NAME --cache_flag_values
# Add firewall rules
gcutil addfirewall port-80 --description="Open up port 80." --allowed="tcp:80"
gcutil addfirewall port-443 --description="Open up port 443." --allowed="tcp:443"
gcutil addfirewall port-8080 --description="Temporarily open up port 8080." --allowed="tcp:8080"
gcutil addfirewall port-8443 --description="Temporarily open up port 8443." --allowed="tcp:8443"
# Work as root
sudo su
# Update Yum and install common CentosOS stuf
yum -y update
yum -y install links
# Install things we need for Node.js
yum -y groupinstall "Development Tools"
yum -y install gcc
yum -y install gcc-c++
yum -y install screen
# Add "git svn" capability to git
yum -y install git
yum -y install git-svn
yum -y install svn
# Install Node.js 0.10.21 and npm
cd /usr/src
wget http://nodejs.org/dist/latest/node-v0.10.21.tar.gz && tar zxf node-v0.10.21.tar.gz && cd node-v0.10.21
bash ./configure
make
make install
# Add non-privileged user (will need to set a password after second command)
# useradd -d /home/cluster-user -m cluster-user
# Add yourself to www group
usermod -G $GOOGLE_COMPUTE_USER,www www
# Configure Apache
# mkdir -p /var/www/public_html
# chown -R www:www /var/www/public_html
# chmod 755 /var/www/public_html
# Symbolically link node_modules (make global modules globally accessible)
sudo ln -s /usr/local/lib/node_modules /node_modules
# Install some useful Node.js modules globally
npm install -g express
npm install -g http-proxy
npm install -g supervisor
# Forward port 80 to 8080 and port 443 to 8443, respectively
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 5672 -j REDIRECT --to-port 12000
service iptables save
service iptables restart
# Save IP Table updates
iptables -F
service iptables save
# Leave sudo
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment