Skip to content

Instantly share code, notes, and snippets.

@jrnickell
Last active August 29, 2015 14:09
Show Gist options
  • Save jrnickell/5bfe468ac372430c45cf to your computer and use it in GitHub Desktop.
Save jrnickell/5bfe468ac372430c45cf to your computer and use it in GitHub Desktop.
Setup Development Machine
#!/usr/bin/env bash
echo -n "==> Choose a password for MySQL and phpMyAdmin: "
read PASSWORD
echo -n "==> Enter your full name for Git configuration: "
read FULLNAME
echo -n "==> Enter your email address for Git configuration: "
read EMAILADD
# initial updates and utilities
sudo apt-get update
sudo apt-get install -qq aptitude wget curl cron build-essential software-properties-common
# debconf utils
sudo apt-get install -qq debconf-utils
# password parameters
echo "mysql-server mysql-server/root_password password $PASSWORD" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again password $PASSWORD" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/dbconfig-install boolean true" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/admin-pass password $PASSWORD" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/mysql/app-pass password $PASSWORD" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/app-password-confirm password $PASSWORD" | sudo debconf-set-selections
echo "phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2" | sudo debconf-set-selections
# repositories
sudo add-apt-repository -y ppa:webupd8team/sublime-text-2
sudo add-apt-repository -y ppa:ondrej/php5-5.6
sudo add-apt-repository -y ppa:ondrej/mysql-5.6
sudo add-apt-repository -y ppa:ondrej/apache2
# update and upgrade
sudo apt-get update
sudo aptitude -y safe-upgrade
# text editors
sudo apt-get install -qq vim sublime-text
# version control
sudo apt-get install -qq git
# openssl
sudo apt-get install -qq openssl
# keychain
sudo apt-get install -qq keychain
# chrome
if [[ $(getconf LONG_BIT) = "64" ]]
then
echo "64bit Detected" &&
echo "Installing Google Chrome" &&
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb &&
sudo dpkg -i google-chrome-stable_current_amd64.deb &&
rm -f google-chrome-stable_current_amd64.deb
else
echo "32bit Detected" &&
echo "Installing Google Chrome" &&
wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb &&
sudo dpkg -i google-chrome-stable_current_i386.deb &&
rm -f google-chrome-stable_current_i386.deb
fi
# fix missing dependencies
sudo apt-get -f install
# git general config
git config --global user.name "$FULLNAME"
git config --global user.email "$EMAILADD"
git config --global color.ui true
git config --global push.default simple
# source code pro
wget http://downloads.sourceforge.net/project/sourcecodepro.adobe/SourceCodePro_FontsOnly-1.017.zip
unzip SourceCodePro_FontsOnly-1.017.zip
mkdir -p ~/.fonts
cp SourceCodePro_FontsOnly-1.017/OTF/*.otf ~/.fonts/
rm -rf SourceCodePro_FontsOnly-1.017
rm SourceCodePro_FontsOnly-1.017.zip
fc-cache -f -v
# apache
sudo apt-get install -qq apache2
# Update apache2.conf with backup
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
cat /etc/apache2/apache2.conf.bak | sed '
/^# Global/ a\
ServerName localhost
' | sudo tee /etc/apache2/apache2.conf
# apache modules
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod filter
sudo a2enmod expires
sudo a2enmod include
sudo a2enmod ssl
# php
sudo apt-get install -qq php5 libapache2-mod-php5 php5-dev
# mysql
sudo apt-get install -y -q mysql-server libapache2-mod-auth-mysql php5-mysql
# sqlite
sudo apt-get install -qq sqlite3
# php.ini settings for development
sudo sed -i "s/^error_reporting.*/error_reporting = E_ALL/" /etc/php5/apache2/php.ini
sudo sed -i "s/^display_errors.*/display_errors = On/" /etc/php5/apache2/php.ini
sudo sed -i "s/^error_reporting.*/error_reporting = E_ALL/" /etc/php5/cli/php.ini
sudo sed -i "s/^display_errors.*/display_errors = On/" /etc/php5/cli/php.ini
sudo sed -i "s/^disable_functions.*/disable_functions = /" /etc/php5/cli/php.ini
sudo sed -i "s/^;date\.timezone.*/date.timezone = UTC/" /etc/php5/apache2/php.ini
sudo sed -i "s/^;date\.timezone.*/date.timezone = UTC/" /etc/php5/cli/php.ini
sudo sed -i "s#^;include_path = \"\.:/usr/share/php\"#include_path = \".:/usr/share/php\"#" /etc/php5/apache2/php.ini
sudo sed -i "s#^;include_path = \"\.:/usr/share/php\"#include_path = \".:/usr/share/php\"#" /etc/php5/cli/php.ini
# php extensions
sudo apt-get install -qq php5-curl php5-intl php5-xdebug php5-xmlrpc php5-xsl php5-sqlite php5-imagick php5-json php5-apcu php5-mcrypt
# phpmyadmin
sudo php5enmod mcrypt
sudo apt-get install -y -q phpmyadmin
# composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
# ssl certificates
sudo mkdir -p /etc/apache2/ssl/000_default
sudo openssl req -x509 -nodes -days 1825 -newkey rsa:2048 -keyout /etc/apache2/ssl/000_default/apache.key -out /etc/apache2/ssl/000_default/apache.crt -subj "/C=US/ST=/L=/O=/OU=/CN=localhost/emailAddress="
# Update 000-default.conf with backup
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bak
cat /etc/apache2/sites-available/000-default.conf.bak | sed '
/^# vim:/ i\
<VirtualHost *:443>\
\
SSLEngine On\
SSLCertificateFile /etc/apache2/ssl/000_default/apache.crt\
SSLCertificateKeyFile /etc/apache2/ssl/000_default/apache.key\
\
# The ServerName directive sets the request scheme, hostname and port that\
# the server uses to identify itself. This is used when creating\
# redirection URLs. In the context of virtual hosts, the ServerName\
# specifies what hostname must appear in the request Host: header to\
# match this virtual host. For the default virtual host (this file) this\
# value is not decisive as it is used as a last resort host regardless.\
# However, you must set it for any further virtual host explicitly.\
#ServerName www.example.com\
\
ServerAdmin webmaster@localhost\
DocumentRoot /var/www/html\
\
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,\
# error, crit, alert, emerg.\
# It is also possible to configure the loglevel for particular\
# modules, e.g.\
#LogLevel info ssl:warn\
\
ErrorLog ${APACHE_LOG_DIR}/error.log\
CustomLog ${APACHE_LOG_DIR}/access.log combined\
\
# For most configuration files from conf-available/, which are\
# enabled or disabled at a global level, it is possible to\
# include a line for only one particular virtual host. For example the\
# following line enables the CGI configuration for this host only\
# after it has been globally disabled with "a2disconf".\
#Include conf-available/serve-cgi-bin.conf\
</VirtualHost>\
' | sudo tee /etc/apache2/sites-available/000-default.conf
# restart apache
cd ~
sudo service apache2 restart
# create bin, projects, and logs directories
mkdir ~/bin
mkdir ~/Projects
mkdir ~/Logs
# download create-vhost and remove-vhost scripts
cd ~/bin
wget "https://raw.githubusercontent.com/jrnickell/bash/master/bin/create-vhost" -O create-project
wget "https://raw.githubusercontent.com/jrnickell/bash/master/bin/remove-vhost" -O remove-project
cd ~
# node install
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
source ~/.nvm/nvm.sh
echo 'export PATH="$PATH:$HOME/.nvm/bin"' | tee -a ~/.bashrc
echo 'source ~/.nvm/nvm.sh' | tee -a ~/.bashrc
nvm install 0.10
nvm use 0.10
nvm alias default 0.10
# bower
npm install -g bower
# ruby install
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -L get.rvm.io | bash -s stable
# source rvm script and add to .bashrc
source ~/.rvm/scripts/rvm
echo 'source ~/.rvm/scripts/rvm' | tee -a ~/.bashrc
# install requirements
rvm requirements
sudo apt-get install -qq libmysqlclient-dev
sudo apt-get install -qq libpq-dev
# add autoupdate flag
echo rvm_autoupdate_flag=2 >> ~/.rvmrc
# ruby
rvm install 2.1.5
rvm use 2.1.5
rvm --default use 2.1.5
# rails
gem install rails
# compass
gem install compass
# java
sudo apt-get install -qq openjdk-7-jre
sudo apt-get install -qq openjdk-7-jdk
# cleanup
cd ~
echo "Cleaning Up" &&
sudo apt-get -f install &&
sudo apt-get autoremove &&
sudo apt-get -y autoclean &&
sudo apt-get -y clean
# Version information
echo -e "\nInstallation Complete!"
echo -e "======================"
echo -e "\nPython Version:"
echo -e "==============="
python -V
echo -e "\nJava Version:"
echo -e "============="
java -version
echo -e "\nNode.js Version:"
echo -e "================"
node --version
echo -e "\nRuby Version:"
echo -e "============="
ruby --version
echo -e "\nApache Version:"
echo -e "==============="
apache2 -v
echo -e "\nMySQL Version:"
echo -e "=============="
mysql -V
echo -e "\nPHP Version:"
echo -e "============"
php -v
echo -e "\nGit Version:"
echo -e "============"
git --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment