Create a gist now

Instantly share code, notes, and snippets.

vagrant bootstrap
#!/usr/bin/env bash
## add redis to the package list
cat <<BAM >> /etc/apt/sources.list.d/dotdeb.org.list
# /etc/apt/sources.lsit.d/dotdeb.org.list
deb http://packages.dotdeb.org squeeze all
deb-src http://packages.dotdeb.org squeeze all
BAM
## import redis public key to package keys
wget -qO - http://www.dotdeb.org/dotdeb.gpg | apt-key add -
## add rabbitmq source to package list
cat <<BAM >> /etc/apt/sources.list.d/rabbitmq.com.list
# /etc/apt/sources.list.d/rabbitmq.com.list
deb http://www.rabbitmq.com/debian/ testing main
BAM
## import rabbitmq public key to package keys
wget -qO - http://www.rabbitmq.com/rabbitmq-signing-key-public.asc | apt-key add -
## add mongodb source to package lit
cat <<BAM >> /etc/apt/sources.list.d/mongodb.list
# /etc/apt/sources.list.d/mongodb.list
deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen
BAM
## import mongodb public key to package keys
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
## update the package list
apt-get update
## install ruby
apt-get install -y ruby1.9.1 ruby1.9.1-dev rubygems1.9.1 irb1.9.1 ri1.9.1 rdoc1.9.1 build-essential libopenssl-ruby1.9.1 libssl-dev zlib1g-dev
## install redis-server
apt-get install -y redis-server
## change redis configuration to bind to all interfaces
/etc/init.d/redis-server stop
sed -i 's/bind 127.0.0.1/# bind 127.0.0.1/g' /etc/redis/redis.conf
/etc/init.d/redis-server start
## install mongodb
apt-get install -y mongodb-org
## change the mongo configuration to bind to all interfaces
sed -i 's/bind_ip = 127.0.0.1/#bind_ip = 127.0.0.1/g' /etc/mongod.conf
service mongod restart
## install rabbitmq
apt-get install -y rabbitmq-server
## enable the management plugin
rabbitmq-plugins enable rabbitmq_management
service rabbitmq-server restart
## add a new administrator user
rabbitmqctl add_user admin admin
rabbitmqctl set_user_tags admin administrator
## add a new development user
rabbitmqctl add_user dev dev
rabbitmqctl set_user_tags dev management
## add a new virtual host
rabbitmqctl add_vhost /development
## set the user permissions
rabbitmqctl set_permissions -p / admin '.*' '.*' '.*'
rabbitmqctl set_permissions -p /development admin '.*' '.*' '.*'
rabbitmqctl set_permissions -p /development dev 'dev.*.*' 'dev.*.*' 'dev.*.*'
## install mysql-server
echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections
apt-get install -y mysql-server
## install apache2
apt-get install -y libcurl4-openssl-dev
apt-get install -y apache2 apache2-mpm-worker apache2-threaded-dev
## remove everything out of the public web directory
## and link the the public web directory to the vagrant share
rm -rf /var/www
ln -fs /vagrant /var/www
## install necessary gems
gem install rake pbkdf2
gem install data_mapper dm-mysql-adapter sinatra sinatra-contrib passenger
## install passenger apache2 module
passenger-install-apache2-module --auto --languages 'ruby'
## create /etc/apache2/mods-available/passenger.load:
cat <<BAM >> /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /var/lib/gems/1.9.1/gems/passenger-4.0.44/buildout/apache2/mod_passenger.so
BAM
## create /etc/apache2/mods-available/passenger.conf:
cat <<BAM >> /etc/apache2/mods-available/passenger.conf
PassengerRoot /var/lib/gems/1.9.1/gems/passenger-4.0.44
PassengerDefaultRuby /usr/bin/ruby1.9.1
BAM
## create /etc/apache2/sites-available/rest-app
cat <<BAM >> /etc/apache2/sites-available/rest-app
<VirtualHost *:80>
ServerName dev.ubuntu.com
DocumentRoot /var/www/rest_site
<Directory /var/www/rest_site>
AllowOverride all
Options -MultiViews
</Directory>
Alias /api /var/www/rest_app/public
<Location /api>
PassengerBaseURI /api
PassengerAppEnv development
PassengerAppRoot /var/www/rest_app
</Location>
<Directory /var/www/rest_app/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
BAM
## enable passenger module
a2enmod passenger
## enable rest-app site
a2ensite rest-app
## reload apache and restart
service apache2 reload
service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment