Last active
May 25, 2016 07:59
-
-
Save 1c7/3c0f517c2e66da148778e332bf896703 to your computer and use it in GitHub Desktop.
Setup Ubuntu 14.04 server for Rails application (I use this to setup UCloud Ubuntu server)
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 | |
| # 2016-5-25 | |
| # Init Ubuntu server 16.04 for Rails application | |
| # Author: Github@1c7 | |
| # Software: | |
| # Nginx | |
| # MySQL | |
| # Git (Capistrano 3 need this) | |
| # NodeJS (Rails need this) | |
| # Ruby | |
| # Ruby on Rails | |
| echo " ================= Update Ubuntu ======================" | |
| sudo apt -y update | |
| echo " ================= Nginx ======================" | |
| sudo apt -y install nginx | |
| echo " ================= MySQL ======================" | |
| sudo apt -y install mysql-server | |
| echo " ================= Some Dependencies ======================" | |
| sudo apt-get -y 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 | |
| echo " ================= NodeJS ======================" | |
| curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - | |
| sudo apt-get install -y nodejs | |
| echo '=================== Ruby ===========================' | |
| cd | |
| git clone https://github.com/rbenv/rbenv.git ~/.rbenv || true | |
| echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
| echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
| exec $SHELL | |
| git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build || true | |
| echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc | |
| exec $SHELL | |
| git clone https://github.com/rbenv/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash || true | |
| rbenv install 2.3.0 | |
| rbenv global 2.3.0 | |
| ruby -v | |
| rails -v | |
| echo '========= Bundler ==============' | |
| gem install bundler | |
| echo '========= Rails ==============' | |
| gem install rails -v 4.2.6 | |
| echo '========= Done! Have a nice day! ==============' |
Author
Author
漏了 git
这里的 Ruby 安装有点问题,要改,地址太慢了。
还有 git 的简写
git config --global alias.s status
git config --global alias.d diff
git config --global alias.a add
git config --global alias.c commit
git config --global alias.pu push
git config --global alias.pl pull
git config --global alias.co checkout
Author
gem install bundle 之后如果 rails s 碰到错误,那就是 bundle install 没运行过
Author
解决方法 https://ruby-china.org/topics/26314
bundle config 'mirror.https://rubygems.org' 'https://ruby.taobao.org'
Author
sudo apt-get install libmysql-ruby libmysqlclient-dev
如果 Rails 的 mysql2 安装失败就
Author
安装 Sublime Text 3
http://askubuntu.com/questions/172698/how-do-i-install-sublime-text-2-3
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
Author
搜狗输入法的安装:
先去官网下载 deb 双击安装
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
后半部分 git clone 那里好像有些问题,没继续执行 clone 后面的代码,
手动复制粘贴就好了。
我也懒得改进了这个脚本了。
我手动跑了下 clone 部分的代码,说是目录已经存在, fatal。
所以要改进的就是做个目录是否存在,存在则跳过的逻辑,改进的话可以从这里着手