Last active
October 5, 2017 16:43
-
-
Save diegobarros0701/150f95a139ecd8d7b1a8c2b7b3314245 to your computer and use it in GitHub Desktop.
Set up Ruby and Rails + MySQL
This file contains 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 | |
echo "Setting up RoR and MySQL environment" | |
echo "Updating repositories..." | |
if ! sudo apt-get update | |
then | |
echo "Can't update the repository." | |
exit 1 | |
fi | |
echo "Repositories updated." | |
echo "Installing needed packages..." | |
if ! sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev nodejs | |
then | |
echo "Can't install the package." | |
exit 1 | |
fi | |
echo "Packages installed." | |
echo "Installing rbenv..." | |
cd | |
sudo rm -rf ~/.rbenv | |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
sudo rm -rf ~/.rbenv/plugins/ruby-build | |
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build | |
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc | |
if ! rbenv install 2.4.2 | |
then | |
echo "Can't install rbenv" | |
exit 1 | |
fi | |
if ! rbenv global 2.4.2 | |
then | |
echo "Can't set up rbenv as global." | |
exit 1 | |
fi | |
echo "Ruby installed!" | |
RUBY_VERSION="$(ruby -v)" | |
echo "Version: ${RUBY_VERSION}" | |
echo "Setting up Rails.." | |
echo "Downloading NodeJS..." | |
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - | |
if ! sudo apt-get install -y nodejs | |
then | |
echo "Can't install NodeJS" | |
exit 1 | |
fi | |
echo "Installing Rails" | |
if ! gem install rails -v 5.1.4 | |
then | |
echo "Can't install Rails" | |
exit 1 | |
fi | |
rbenv rehash | |
echo "Rails installed" | |
RAILS_VERSION="$(rails -v)" | |
echo "Version: ${RAILS_VERSION}" | |
echo "Installing MySQL" | |
if ! sudo apt-get install mysql-server mysql-client libmysqlclient-dev | |
then | |
echo "Can't install MySQL" | |
exit 1 | |
fi | |
echo "MySQL installed." | |
echo "Your environment is ready!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment