Skip to content

Instantly share code, notes, and snippets.

@xecutioner
Created March 20, 2017 06:40
Show Gist options
  • Save xecutioner/ec48cf2a7cb45d6a917212be046761f1 to your computer and use it in GitHub Desktop.
Save xecutioner/ec48cf2a7cb45d6a917212be046761f1 to your computer and use it in GitHub Desktop.

Setting up linux server using Ngix.

Steps to set up a server.

  • set up a hostname for your new server. hostnamectl set-hostname hostname
  • Set up a timezone for your new server. dpkg-reconfigure tzdata

Securing your server.

  • add user [ adduser user_name groups ]
  • Set up a ssh access for your new server. ssh-keygen -b 4096 with a passphrase. ssh-copy-id username@ip
    • Disable Password authentication /etc/ssh/sshd_config

    • Listen on only IPV4 : echo 'AddressFamily inet' | sudo tee -a /etc/ssh/sshd_config

    • sudo systemctl restart sshd

Set up your ruby version manager .

  • Set up your deploy user

    • source /etc/profile.d/rvm.sh (To reload shell with rvm command loaded)
  • Install phusion passenger.

    • gem install passenger
  • Install nginx .

    • rvmsudo passenger-install-nginx-module
    • General nginx server module
     	http {
       	 ...
       	 passenger_root /usr/local/rvm/gems/ruby-2.4.0/gems/passenger-5.1.2;
         passenger_ruby /usr/local/rvm/gems/ruby-2.4.0/wrappers/ruby;
         ...
     	  }
    
    • Start your nginx : /opt/nginx/sbin ./nginx
  • Set up your deployment script. [ Capistrano ] https://github.com/capistrano/rails

     	{13:12}[2.4.0]~/dev/alphacamp-sg/Ecommerce:cart ✗ ➭ bundle exec cap install                                                                                 
    
     	
     	mkdir -p config/deploy
     	create config/deploy.rb
     	create config/deploy/staging.rb
     	create config/deploy/production.rb
     	mkdir -p lib/capistrano/tasks
     	create Capfile
     	Capified
    

- Set up your hosting configurations. 

**References:**

- [Linode Quick Start Guide](https://www.linode.com/docs/getting-started)
- [Rvm multiuser Installation](https://rvm.io/rvm/install)
- [Passenger Web App server](https://www.phusionpassenger.com/)
- [Nginx](https://www.nginx.com/resources/wiki/)
- [Capistrano](https://github.com/capistrano/rails)
- [Symlinks](https://www.cyberciti.biz/tips/understanding-unixlinux-symbolic-soft-and-hard-links.html)

**OPTIONAL FURTHER READS**
- [Ansible](https://www.ansible.com/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment