Skip to content

Instantly share code, notes, and snippets.

@robwilkerson
robwilkerson / vagrant-provision-php.ini.sh
Created November 5, 2013 01:54
Modify php.ini to turn on errors for debugging and disable the short open tag.
# Show PHP errors
sed -i -r -e 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/fpm/php.ini
sed -i -r -e 's/error_reporting = E_ALL & ~E_DEPRECATED/error_reporting = E_ALL | E_STRICT/g' /etc/php5/fpm/php.ini
sed -i -r -e 's/display_errors = Off/display_errors = On/g' /etc/php5/fpm/php.ini
@robwilkerson
robwilkerson / vagrant-set-hostname.sh
Created August 1, 2013 13:01
Sets and persists a custom hostname on an Ubuntu server.
# Set a helpful hostname as a convenient reference.
echo "project-name" > /etc/hostname
echo "127.0.0.1 project-name" >> /etc/hosts
hostname project-name
@robwilkerson
robwilkerson / install-db.sh
Created June 25, 2013 16:24
Creates and populates a local (Vagrant) database from a remote production source database.
echo "--> Creating a fresh database..."
mysql -uroot --execute "DROP DATABASE IF EXISTS <db_name>; CREATE DATABASE <db_name> CHARACTER SET utf8 COLLATE utf8_unicode_ci;"
echo "<-- Complete."
echo "--> Configuring SSH access to production resources for `id -un`..."
mkdir ~/.ssh
cp /vagrant/.ssh/<name>.pem ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*
SSH_OPTIONS=''
@robwilkerson
robwilkerson / install-varnish.sh
Created June 19, 2013 13:15
Installs Varnish. Tested in a Vagrant shell provisioner for a Ubuntu 12.04 VM.
# Install Varnish
if [ -z `command -v varnishd` ]; then
echo -n "Installing varnish (http://www.varnish-cache.org)..."
# curl http://repo.varnish-cache.org/debian/GPG-key.txt | sudo apt-key add - > /dev/null
# echo "deb http://repo.varnish-cache.org/ubuntu/ precise varnish-3.0" | sudo tee -a /etc/apt/sources.list > /dev/null
apt-get install varnish -qq -y > /dev/null
echo "complete."
else
echo "Varnish is aleady installed."
fi
@robwilkerson
robwilkerson / generate-self-signed-cert.sh
Last active December 17, 2015 14:59
Generates a self-signed SSL certificate. #bash #ssl
# Generate a self-signed certificate
echo -n "Generating a self-signed SSL cert..."
openssl req -new -x509 -days 365 -subj "/C=US/ST=MD/L=Baltimore/O=Rob Wilkerson Consulting, LLC/CN=*.MYDOMAIN.COM" -nodes -out /etc/ssl/certs/wildcard-cert.pem -keyout /etc/ssl/private/wildcard-cert.key
echo "complete."
@robwilkerson
robwilkerson / update-nginx-conf.sh
Created May 22, 2013 15:21
Enables gzip and adjusts for a Virtualbox bug w/ sendfile.
# Tweak the Nginx conf. sendfile is broken on Virtualbox.
echo -n "Setting the Nginx configuration..."
sed -i -r -e 's/sendfile\s*on/sendfile off/g' /etc/nginx/nginx.conf
sed -i -r -e 's/^(\s*)#\s*gzip on(.*)$/\1gzip on\2/' /etc/nginx/nginx.conf
sed -i -r -e 's/^(\s*)#\s*gzip_types(.*)$/\1gzip_types\2/' /etc/nginx/nginx.conf
@robwilkerson
robwilkerson / configure-memcached-php5.sh
Created May 22, 2013 15:15
Configures Memcached for use with PHP.
if grep -Fxq 'memcache.hash_strategy="consistent"' /etc/php5/conf.d/memcache.ini; then
echo "Memcache configuration updates have already been made."
else
echo -n "Updating the memcached config..."
echo 'memcache.hash_strategy="consistent"' >> /etc/php5/conf.d/memcache.ini
echo "complete."
fi
@robwilkerson
robwilkerson / install-dnsmasq.sh
Created May 22, 2013 15:12
Installs DNSMasq. Tested in a Vagrant shell provisioner for a Ubuntu 12.04 VM.
# Installing dnsmasq so that loopback communication using the site URL doesn't fail.
if [ ! -e '/etc/dnsmasq.conf' ]; then
echo -n "Installing and configuring DNSMasq..."
apt-get install dnsmasq -qq -y > /dev/null 2>&1
cat >> /etc/dnsmasq.conf << "EOF"
address=/.umassmemorial.org/127.0.0.1
listen-address=127.0.0.1
EOF
sed -i -r -e 's/^(\s*)#(\s*prepend domain-name-servers\s+.*)$/\1\2/' /etc/dhcp/dhclient.conf
service dnsmasq restart > /dev/null
@robwilkerson
robwilkerson / install-compass.sh
Created May 22, 2013 15:11
Scripted install of Compass. Tested in a Vagrant shell provisioner for a Ubuntu 12.04 VM.
echo -n "Installing compass (http://compass-style.org)..."
apt-get update -qq -y
apt-get install ruby1.9.1 -qq -y > /dev/null
gem install rubygems-update > /dev/null
update_rubygems > /dev/null
gem install compass > /dev/null
echo "complete."
@robwilkerson
robwilkerson / externalip.sh
Created May 14, 2013 14:32
Display the external IP address of a Unix server.
curl http://ipecho.net/plain; echo