Last active
August 29, 2015 13:56
-
-
Save tony612/9224075 to your computer and use it in GitHub Desktop.
Setup a new server for rails
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
| # login to server | |
| $ ssh [email protected] | |
| # change password | |
| $ passwd | |
| # add user | |
| $ adduser user | |
| # Add Root Privileges to the user | |
| $ visudo | |
| # add `user ALL=(ALL:ALL) ALL` below `root ALL=(ALL:ALL) ALL` | |
| # then.. | |
| $ ctrl-x | |
| # Set a hostname | |
| $ echo "plato" > /etc/hostname | |
| $ hostname -F /etc/hostname | |
| # In your own mac | |
| $ echo "12.34.56.78 plato.com plato" >> /etc/hosts | |
| # So that you can | |
| $ ssh [email protected] | |
| $ mkdir ~/.ssh | |
| # brew install ssh-copy-id | |
| $ ssh-copy-id [email protected] | |
| # or | |
| # scp ~/.ssh/id_rsa.pub [email protected]:/home/user/.ssh/uploaded_key.pub | |
| # ssh [email protected] "echo `cat ~/.ssh/uploaded_key.pub` >> ~/.ssh/authorized_keys" | |
| # so that ~/.ssh/authorized_keys of server will have your pub key | |
| # and you can login without a password | |
| $ ssh [email protected](without a password) | |
| # Disable the password login | |
| $ sudo vim /etc/ssh/sshd_config | |
| change `PermitRootLogin true` to `PermitRootLogin without-password` | |
| # update and reboot | |
| $ sudo apt-get update | |
| $ sudo apt-get upgrade | |
| $ sudo reboot | |
| $ sudo apt-get install zsh | |
| $ chsh -s /bin/zsh | |
| $ sudo apt-get install git | |
| $ curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh | |
| $ source ~/.zshrc | |
| $ sudo apt-get install curl | |
| $ curl -L get.rvm.io | bash -s stable | |
| $ source ~/.rvm/scripts/rvm | |
| $ rvm requirements # need password | |
| $ rvm install ruby-2.1.1 | |
| $ sudo apt-get nodejs | |
| $ gem install bundler | |
| $ sudo apt-get install nginx | |
| $ gem install unicorn | |
| $ sudo apt-get install postgresql postgresql-server-dev-9.1 | |
| $ sudo -u postgres psql | |
| $ create user username with password 'password'; | |
| $ create database projectname_production owner username; # Remember to set host to localhost in database.yml | |
| # When you use pg in commandline, you may meet the problem 'Peer authentication failed for user ""' | |
| # You can try add "export PGHOST=localhost" to ~/.zshrc | |
| change user role: http://www.postgresql.org/docs/9.1/static/sql-alteruser.html | |
| # Rails deploy | |
| # refer to https://github.com/tony612/mina-rails-unicorn-nginx-god |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment