Skip to content

Instantly share code, notes, and snippets.

@ziaulrehman40
Last active August 21, 2023 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ziaulrehman40/0e3afe55d5d1f93e5bfb02f5a117567c to your computer and use it in GitHub Desktop.
Save ziaulrehman40/0e3afe55d5d1f93e5bfb02f5a117567c to your computer and use it in GitHub Desktop.
Ubuntu setup for rails

Basic use libraries installation

sudo apt update
sudo apt install unace unrar zip unzip p7zip-full p7zip-rar sharutils gnupg2 rar uudeview mpack arj cabextract file-roller

Actual Development Setup

Essentials

sudo apt-get install curl git gitk

RVM

curl -L get.rvm.io | bash -s stable 

If it fails run these commands and try again:

command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

ALTERNATIVELY, if you face unfixable issues you may follow https://github.com/rvm/ubuntu_rvm and skip this section)

  • CAREFULLY READ OUTPUT OF THIS COMMAND, THERE WILLL BE FAILURE PROBABLY, AND IT WILL TELL HOW TO FIX THIS FAILURE

  • IT WILL GIVE SOME LINE SIMILAR TO BELOW LINE, SEE PREVIOUS COMMAND OUTPUT FOR ACTUAL COMMAND gpg2 --keyserver hkp://keys.gnupg.net --recv-keys XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • AFTER FOLLOWING INSTRUCTIONS RE-RUN THE COMMAND I.E:

curl -L get.rvm.io | bash -s stable

rvm -v if it fails, try closing and re-opening terminal window

rvm list

Other dependencies

sudo apt-get install build-essential openssl libreadline6-dev 
rvm install 2.7
rvm install 3.0
(Now we will install nvm for node version managaement, it will help when you will move to different projects)
(Follow instructions here: https://github.com/nvm-sh/nvm#install--update-script )
(restart terminal)
nvm install 14
gem -v
rvm list
rvm -v
gem install bundler
gem install bundler -v 1.17
gem install rails
bundle (only if you are in a rails project directory, skip otherwise)

Postgres and PGAdmin4

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

*For simple instalation

sudo apt install postgresql pgadmin4

For PL/Python support(skip if you don't know what that is)

Don't forget to replace 10 with 9 in following command if you need postgres 9

sudo apt-get install postgresql postgresql-10 postgresql-plpython-10 pgadmin4

Below are common steps for initial setup of DB user

sudo -u postgres psql postgres 
# \password postgres (SET PASSWORD FOR 'POSTGRES' USER)
# \q (to exit psql terminal)
exit

Redis

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install redis-server

sudo update-rc.d redis-server enable
sudo update-rc.d redis-server defaults
sudo systemctl restart redis-server.service
sudo systemctl enable redis-server.service
redis-benchmark -q -n 1000 -c 10 -P 5

GDebi, npm and linters for sublime

sudo apt-get install gdebi npm
npm install -g sass-lint eslint stylelint coffeelint htmlhint typings   (if fails, try with sudo)

Random (not needed 99.9% of times)

// IF YOU NEED, postgres backup and restore...(with roles etc) below are some commands for record. pg_dumpall -U ziap1 -h localhost > db_backupall (to backup from old system) psql -f db_backupall postgres -U postgres -h localhost (to restore on new system)

@mehroz-muzaffar-dev
Copy link

gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.7.0 directory.

Try Adding "sudo" before above command like as follows:
sudo gem install bundler

@hassaan1536
Copy link

Command : curl -L get.rvm.io | bash -s stable
Gave Permission Denied Error
Solution : rvm fix-permissions system; rvm fix-permissions user
Fixed For Me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment