Skip to content

Instantly share code, notes, and snippets.

@firewalker06
Last active August 29, 2015 14:00
Show Gist options
  • Save firewalker06/11239697 to your computer and use it in GitHub Desktop.
Save firewalker06/11239697 to your computer and use it in GitHub Desktop.
Centos 6.5 with Ruby 2.1.0 and Nginx

Yummy update

$ yum update

Install Git, Curl, and Vim

$ yum install curl git vim`
$ git config --global user.name "Your name"
$ git config --global user.email "[email protected]"

Install RVM and Ruby 2.1.0

$ curl -L get.rvm.io | bash -s stable
$ source /etc/profile.d/rvm.sh
$ rvm install 2.1.0
$ rvm use 2.1.0 --default
$ gem install bundle

Nginx

$ yum install nginx

Set iptables to accept traffic from port 80

Put this line just before -A INPUT -j REJECT --reject-with icmp-host-prohibited in /etc/sysconfig/iptables file:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Then restart iptables:

$ /etc/init.d/iptables restart

Create Non-Root user

This will create user rails without password and group deploy. Use key pair to access server.

$ useradd rails
$ groupadd deploy
$ usermod -a -G deploy rails

Run visudo and append this line so that user can access sudo:

rails ALL=(ALL) ALL

Copy authorized_keys from root to new user directory and change its permission, so that we can use the same public key:

$ cp /root/.ssh/authorized_keys /home/rails/.ssh/authorized_keys
$ chmod 0440 /home/rails/.ssh/authorized_keys
$ chown rails:deploy /home/rails/.ssh/authorized_keys
$ chattr +i /home/rails/.ssh/authorized_keys

Change ssh configuration /etc/ssh/sshd_config to disable Root login and ask for password:

PermitRootLogin no
PasswordAuthentication no

Then run sudo /etc/init.d/sshd restart to restart SSH config. DON'T LOGOUT FROM SSH until you are sure that you can ssh and sudo su with the new user.

Expand Volume

#list volumes
lsblk
#expand volume
sudo resize2fs /dev/xda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment