Last active
January 27, 2016 10:18
-
-
Save lesleh/4452206ea9293661d908 to your computer and use it in GitHub Desktop.
Production server setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export GITHUB_USERNAME=lesleh | |
export GITHUB_PASSWORD=hunter2 | |
export DB_ROOT_PASSWORD=password | |
# Delete the next two lines when you're done | |
>&2 echo "YOU NEED TO SET THE VARIABLES BEFORE RUNNING THE SCRIPT.." | |
exit 1 | |
# I'm not typing a million times | |
if [[ $EUID -ne 0 ]]; then | |
exec $0 | |
exit | |
fi | |
echo Updating system | |
apt-get update -y | |
apt-get upgrade -y | |
apt-get install -y curl | |
if [ ! -d $HOME/.ssh ]; then | |
echo Generating a keypair | |
mkdir $HOME/.ssh | |
ssh-keygen -b 2048 -t rsa -f $HOME/.ssh/id_rsa -q -N "" | |
fi | |
echo Adding public key to your GitHub account | |
curl --user $GITHUB_USERNAME:$GITHUB_PASSWORD https://api.github.com/user/keys \ | |
--data "{\"title\": \"AUTOADDED KEY\", \"key\": \"$(cat $HOME/.ssh/id_rsa.pub)\"}" | |
echo RVM stuffs | |
echo "gem: --no-document" >> ~/.gemrc | |
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 | |
\curl -sSL https://get.rvm.io | bash | |
source /home/leslie/.rvm/scripts/rvm | |
rvm install ruby | |
echo "source \$HOME/.rvm/scripts/rvm" >> $HOME/.bashrc | |
echo "rvm use ruby" >> $HOME/.bashrc | |
gem install bundler | |
echo Installing mysql with root password of 'password' | |
echo mysql-server mysql-server/root_password password $DB_ROOT_PASSWORD | debconf-set-selections | |
echo mysql-server mysql-server/root_password_again password $DB_ROOT_PASSWORD | debconf-set-selections | |
apt-get install -y mysql-server libmysqlclient-dev | |
# Ensure MySQL is configured for utf-8 | |
cat << EOF > /etc/mysql/conf.d/collations.cnf | |
[mysql] | |
default-character-set=utf8 | |
[mysqld] | |
character-set-server = utf8 | |
collation-server = utf8_unicode_ci | |
skip-character-set-client-handshake | |
EOF | |
echo Installing latest git | |
apt-add-repository -y ppa:git-core/ppa | |
apt-get update | |
apt-get install -y git | |
echo Installing RGeo | |
apt-get install -y libgeos-dev | |
echo Fixing symlinks | |
GEOS_SO=$(find /usr/lib -maxdepth 1 -name "libgeos-*.so") | |
ln -s $GEOS_SO /usr/lib/libgeos.so.1 | |
ln -s /usr/lib/libgeos.so.1 /usr/lib/libgeos.so | |
# TODO Search server | |
# TODO Nginx + passenger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment