sh 在Debian上安装Rails

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在Debian上安装Rails相关的知识,希望对你有一定的参考价值。

#!/bin/bash

# To use, run the following command:
# curl https://gist.github.com/91667973bf4916ea2e31a90255a136f7.git >> install.sh && sh install.sh

# Make sure we have the latest packages
echo '\n#### Updating Packages ####\n'
	sudo apt-get update

# Install git
echo '\n#### Installing Git ####'
if hash git 2>/dev/null ; then
	echo 'Already Installed'
else 
	sudo apt-get --assume-yes install git-core
fi


## Install Postgres
echo '\n#### Installing Postgres ####'
if hash psql 2>/dev/null ; then
	echo 'Already Installed'
else 
	# install pg and pg dev libraries
	sudo apt-get --assume-yes install postgresql postgresql-contrib libpq-dev
	# create super user
	sudo -u postgres createuser -s root
	# set password 
	#sudo -u postgres postgresql
fi


# Install Rbenv
echo '\n#### Installing Rbenv ####'
if hash rbenv 2>/dev/null ; then
	echo 'Already Installed'
else 
	if [ ! -d '/root/.rbenv' ] ; then
		git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
		# set the paths & shims 
		echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
		echo 'eval "$(rbenv init -)"' >> ~/.bashrc
		
		# install ruby-build
		git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
		# install gem rehash
		git clone https://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
		# relod bash
		$(basename $0) && exit
	fi
fi

## Install Ruby
echo '\n#### Installing Ruby ####'
if hash ruby 2>/dev/null ; then
	echo 'Already Installed'
else 
		# install required packages
	apt-get install build-essential libssl-dev libcurl4-openssl-dev libreadline-dev -y
	# Install ruby with Ruby source (helps build some gems)
	rbenv install 2.3.1 -k
	# set the global Ruby version
	rbenv global 2.3.1
	$(basename $0) && exit
fi
$(basename $0) && exit
# Install Rails 
gem install rails 

# Install Gems
gem install 'pg'

以上是关于sh 在Debian上安装Rails的主要内容,如果未能解决你的问题,请参考以下文章

sh 在Debian上安装zRAM(8)

sh 在Debian上安装zRAM(8)

sh 在Debian Jessie上安装Salt

sh 如何在Debian / Ubuntu上安装PhantomJS

sh 在Debian / Ubuntu Linux上安装Azure CLI

sh 在基于Debian的系统上安装Oracle JDK 8。