CentOS上安装配置Ruby on Rails

0.install sublime editor(optional)
ref:http://www.tecmint.com/install-sublime-text-editor-in-linux/


1.install git
$sudo yum install git
$git --verison
2.install rbenv
$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l
$ rbenv --version
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
$ rbenv install -l //show avaliable ruby
3.install package
$sudo yum install openssl-devel
4.install ruby
$rbenv install 2.2.2
$rbenv versions
$rbenv global 2.2.2
$ruby -v
5.install rails
$gem install rails
$rails -v
6.install sqlite and mysql
$echo "options single-request-reopen" >> /etc/resolv.conf
$ sudo yum install sqlite
$ sudo yum install sqlite-devel
$sudo yum install epel-release //get from epel repo as nodejs is not published for centos
$sudo yum install nodejs
$node -v
//http://nomnel.net/blog/install-mysql/ //cannot start mysql server
//$sudo yum install mysql-server
//$sudo yum install mysql-devel
//So I did below
//reference link:http://weblabo.oscasierra.net/installing-mysql-rhel6-with-yum/
$yum -y install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
$yum info mysql-community-server
$yum -y install mysql-community-server
$mysqld --version
$mysql --version
$sudo chkconfig mysqld on //set mysqld start automaticlly
$service mysqld start
7. clone remote sourcefiles and start
$git clone https://....git //need to replace 
this line with your url.
$cd splunkportal
$vi config/config.yml
$vi config/database.yml
$vi Gemfile //need to change the version of rails as you installed
$vi .ruby-version (change ruby version to 2.2.2,not 2.2.2p95) 
$bundle install
$sudo gem install rake
$rake db:create
$rake db:migrate
$rails server //if it shows "Listening on tcp://localhost:3000" success!
8. setup git
$git config --global user.name "Your Name"
$git config --global user.email you@example.com
$git config --global core.editor "subl -w" //set sublimetext as editor (sublimetext must be 
installed)
$cd splunkportal //make sure directory is app directory
$git remote -v //List your existing remotes in order to get the name of the remote you want to 
change.
$git remote set-url origin https://....git
$git remote -v //can see both fetch and push are changed to the url you set
9.Development
$git checkout -b NewBranch //create a branch namely "NewBranch"
$git branch //confirm branch
... //change source code
$git status //confirm status
$git add .
$git commit -m "My First Commit"
$git log
$git push -u origin NewBranch //push to remote NewBranch
$git checkout master //Switch local branch to branch 'master'
$git merge NewBranch //update local master(merge with NewBranch), remote master have not changed
$git push -u origin master //push local master to remote master, now github master branched updated.


posted on 2017-08-20 16:10  blfbuaa  阅读(261)  评论(0编辑  收藏  举报