Skip to content

Instantly share code, notes, and snippets.

@xeoncross
Last active July 26, 2021 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xeoncross/3b8ed1d094707bc0dff8 to your computer and use it in GitHub Desktop.
Save xeoncross/3b8ed1d094707bc0dff8 to your computer and use it in GitHub Desktop.
Modern Development for Go, PHP, Ruby, and Node.js

Simple Developer Setup

Building a cross-platform, unit-tested, continuous-integration, continu͞ou̵s deployment, yeoman͜, grunt/gulp, ionic, ҉angular material, go, sass/less, n̷ode͜js͢, ́so̵cket͏i͘o, n҉i̧g͠htm̶are͡.!?̷҉?͏̷̧̛͜͟

I can help.

Here, use vagrant + this script and have a working virtual ubuntu box totally setup in minutes.

git clone https://gist.github.com/3b8ed1d094707bc0dff8.git ./YOUR_PATH_HERE
vagrant up
vagrant ssh

Already have an ubuntu/debian VPS or Vagrant box setup? Installing the cargo-cult party is easy:

curl -sSL https://gist.githubusercontent.com/Xeoncross/3b8ed1d094707bc0dff8/raw/6cb3ae0e6d836114c60dfdcc518f603e2d040d99/install.sh | bash

Or you can log into the server and manually run the install:

git clone https://gist.github.com/3b8ed1d094707bc0dff8.git ./YOUR_PATH_HERE
./install.sh
#!/bin/bash
##################################
# This Ubuntu/Debian script installs Go, Ruby, Node, and PHP support packages for modern web application development.
# This means LESS, SASS, Gems, NPM, Composer, Ionic, Yeoman, GOPATH, etc...
#
# - Go, GOPATH, GVM
# - Ruby, Gems, RVM
# - Node.js, NPM, NVM
# - Composer [PHP]
#
# To install, run this command:
# curl -sSL https://gist.githubusercontent.com/Xeoncross/3b8ed1d094707bc0dff8/raw/62c88a1855cccb9c365b57c7afab80894fd06a32/install.sh | bash
#
##################################
# benchmark the time to setup the server
_start_time=`date +%s`
function print_warn {
echo -n -e '\e[1;33m'; echo -n "$1"; echo -e '\e[0m'
}
function print_success {
echo -n -e '\e[1;32m'; echo -n "$1"; echo -e '\e[0m'
}
function print_error {
echo -n -e '\e[1;31m'; echo -n "$1"; echo -e '\e[0m'
}
function exit_error {
print_error "$1" && exit 1
}
if [ $(id -u) = 0 ]; then
print_warn "WARNING: running as root"
echo "Stop if running in vagrant (CTRL + C)"
sleep 5
wait
else
echo "Running as: " $(whoami)
sleep 3
wait
fi
if [[ ! -e /etc/debian_version ]]; then
exit_error "You must be running debian or ubuntu to use this"
fi
########################################
# Update our fresh system before we get started
sudo apt-key update
sudo apt-get -qq update
sudo apt-get -qq install git curl wget mercurial bzr htop
# Install PHP
sudo apt-get -qq install git curl wget php5-cli
# PHP
if [[ ! -e /usr/local/bin/composer ]]; then
curl -sS https://getcomposer.org/installer | php
wait
sudo mv composer.phar /usr/local/bin/composer
print_success "Composer installed to /usr/local/bin/composer"
fi
#
# Go
#
sudo apt-get -qq install bison gcc golang-go golang-src
# https://github.com/moovweb/gvm
if [[ $? == 0 ]]; then
if [[ ! -e ~/.gvm/scripts/gvm ]]; then
print_success "Installing GVM"
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
fi
fi
# This sets the gopath relative to your account
if [[ ! -d ~/Go/ ]]; then
echo "export GOPATH=~/Go" >> ~/.profile
mkdir -p ~/Go/{bin/,pkg/,src/}
print_success "Setup GOPATH=~/Go"
fi
#
# Ruby with Gems
#
if [[ ! -e ~/.rvm ]]; then
print_success "Installing RVM"
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
curl -sSL https://get.rvm.io | bash -s stable --ruby
fi
#
# Node.js and NPM
#
# https://github.com/creationix/nvm
if [[ ! -e ~/.nvm ]]; then
print_success "Installing NVM"
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
#wait
sleep 4
# s͢h̶èl̷l ͢rel͡oa҉d̕ hąck
exec bash
source ~/.{profile,bashrc}
nvm install 0.11
nvm use 0.11
nvm alias default 0.11
npm install --global yo bower grunt-cli
# exit s҉hell
exit
fi
########################################
print_success "Setup Complete"
# caculate time
_end_time=`date +%s`
_processing_time=$((_end_time-_start_time))
[[ -z $2 ]] && echo "$_processing_time seconds"
echo ""
print_error "### YOU ARE NOT DONE ###"
echo ""
print_warn "Please refresh your console session by running:"
print_success " source ~/.{profile,bashrc}"
echo ""
print_warn "Then you can begin by picking the version of node you want to use:"
print_success " nvm install 0.10"
print_warn "and installing npm packages:"
print_success " npm install --global yo bower grunt-cli jshint less gulp coffee-script cordova ionic"
echo ""
print_warn "Ruby is also setup, so you can also install gem packages:"
print_success " gem install sass compass"
exit 0
#!/bin/bash
# Uninstall what was installed
function print_warn {
echo -n -e '\e[1;33m'; echo -n "$1"; echo -e '\e[0m'
}
function print_success {
echo -n -e '\e[1;32m'; echo -n "$1"; echo -e '\e[0m'
}
function print_error {
echo -n -e '\e[1;31m'; echo -n "$1"; echo -e '\e[0m'
}
function exit_error {
print_error "$1" && exit 1
}
if [[ $(whoami) == "root" ]]; then
print_warn "Warning, running as root instead of yourself"
fi
if [[ ! -e /etc/debian_version ]]; then
exit_error "You must be running debian or ubuntu to use this"
fi
########################################
# benchmark the time
_start_time=`date +%s`
# Remove npm packages
npm uninstall -g yo bower grunt-cli jshint less gulp coffee-script cordova ionic
# @todo: remove gem itself
gem cleanup compass
gem cleanup sass
# Remove Ruby VM
rvm implode
# Remove the project folders
rm -rf ~/.{gvm,rvm,nvm,npm}
# Remove composer
sudo rm /usr/local/bin/composer
# Remove PHP
sudo aptitude purge php5-cli
# Remove .bashrc lines
sed -i '/NVM_DIR/d' ~/.bashrc
sed -i '/gvm\/scripts\/gvm/d' ~/.bashrc
sed -i '/\/.rvm\//d' ~/.bashrc
# Remove .profile lines
sed -i '/\/.rvm\//d' ~/.profile
sed -i '/export GOPATH=/d' ~/.profile
# Now refresh our shell
source ~/.{bashrc,profile}
########################################
print_success "Uninstall Complete"
# caculate time
_end_time=`date +%s`
_processing_time=$((_end_time-_start_time))
[[ -z $2 ]] && echo "$_processing_time seconds"
echo ""
print_warn "Please refresh your console session by running:"
print_success "source ~/.{profile,bashrc}"
exit 0
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# precise32/64 are two of the most common vagrant boxes ever
# If you want something more current, try:
# http://brightbox.com/vagrant/images/
# https://cloud-images.ubuntu.com/vagrant/trusty/current/
# Old and busted
#config.vm.box = "precise64"
#config.vm.box_url = "http://files.vagrantup.com/precise64.box"
# New hotness (Lua package names, PHP 5.5, nginx 1.4, more chocolate-chip cookies and milk)
config.vm.box = "trusty64"
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
# The hostname the machine should have. If not given, Vagrant won't manage the hostname.
# config.vm.hostname "vagrant-trusty64"
# If you want to set the VM's private address
# https://docs.vagrantup.com/v2/networking/private_network.html
# config.vm.network "private_network", :type => "dhcp"
config.vm.network "private_network", :ip => "192.168.100.100"
# http, mysql, pgsql, mongo, redis, and rtmp port forwarding
# (first 2 digits of port x2 = localhost port number)
config.vm.network :forwarded_port, guest: 80, host: 8080, auto_correct: true
config.vm.network :forwarded_port, guest: 3306, host: 3333, auto_correct: true
#config.vm.network :forwarded_port, guest: 5432, host: 5454, auto_correct: true
#config.vm.network :forwarded_port, guest: 27017, host: 2727, auto_correct: true
#config.vm.network :forwarded_port, guest: 6379, host: 6363, auto_correct: true
#config.vm.network :forwarded_port, guest: 1935, host: 1935, auto_correct: true
# share this current folder with the virtual box
config.vm.synced_folder ".", "/vagrant"
# Also sync the www directory
# config.vm.synced_folder "www", "/var/www/", :nfs => true
# If true, then any SSH connections made will enable agent forwarding.
config.ssh.forward_agent = true
# Give this machine some power (default is 1 core and <500MB RAM)
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--memory", 1024]
vb.customize ["modifyvm", :id, "--cpus", 1]
end
####################################
# Provisioning using shell scripting
####################################
# update before we start
# config.vm.provision :shell, :inline => "sudo apt-get update --fix-missing"
# copy the custom hosts file to the vm
config.vm.provision :shell, :inline => "sudo -H -u vagrant bash /vagrant/install.sh"
# path to the shell script to install everything (or run once you `vagrant ssh` into the box)
#config.vm.provision :shell, :path => "user.sh"
end
@xeoncross
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment