Ref:
https://gorails.com/setup/ubuntu/16.04
https://medium.com/@rgdev/how-to-install-ruby-rails-on-ubuntu-16-04-from-scratch-quickly-4da73c67daa3
I think I already installed many packages needed like curl, nodejs and yarn. so just install this:
|
1 |
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev |
Use rbenv to install ruby 2.6.3 at home:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
git clone https://github.com/rbenv/rbenv.git ~/.rbenv 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 echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL rbenv install 2.6.3 rbenv global 2.6.3 ruby -v |
output:
|
1 2 |
teddy@teddy:~$ ruby -v ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux] |
NOTE: Instal ruby 2.6.2 AND make it default:
|
1 2 3 |
rbenv install 2.6.2 rbenv global 2.6.2 ruby -v |
CHECK:
|
1 2 |
teddy@teddy:~/Documents/ruby$ ruby -v ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-linux] |
Then install ‘bundler’
|
1 2 3 4 5 6 7 8 |
teddy@teddy:~$ gem install bundler Fetching bundler-2.0.2.gem /home/teddy/.rbenv/rbenv.d/exec/gem-rehash/rubygems_plugin.rb:6: warning: Insecure world writable dir /home/teddy/.composer/vendor/bin in PATH, mode 040777 Successfully installed bundler-2.0.2 Parsing documentation for bundler-2.0.2 Installing ri documentation for bundler-2.0.2 Done installing documentation for bundler after 1 seconds 1 gem installed |
I already setup git, so no need to set it up again. check
|
1 2 |
teddy@teddy:~$ ssh -T git@github.com Hi advcha! You've successfully authenticated, but GitHub does not provide shell access. |
Install Rails (v6.0.0.rc1)
|
1 |
teddy@teddy:~$ gem install rails -v 6.0.0.rc1 |
If you’re using rbenv, you’ll need to run the following command to make the rails executable available:
|
1 |
teddy@teddy:~$ rbenv rehash |
check:
|
1 2 |
teddy@teddy:~$ rails -v Rails 6.0.0.rc1 |
SETUP MYSQL
Install libmysqlclient-dev gives you the necessary files to compile the mysql2 gem which is what Rails will use to connect to MySQL when you setup your Rails app.
|
1 |
teddy@teddy:~$ sudo apt-get install libmysqlclient-dev |
Let’s create your first Rails application (with mysql):
|
1 |
teddy@teddy:~/Documents/ruby$ rails new first-app-mysql -d mysql |
then modify /home/teddy/Documents/ruby/first-app-mysql/config/database.yml. Modify the database username, password and db name:
Create the database manually or run ‘rake db:create’
|
1 2 3 |
teddy@teddy:~/Documents/ruby/first-app-mysql$ rake db:create Database 'first_app_mysql' already exists Created database 'first_app_mysql_test' |
Then run ‘rails server’
|
1 |
teddy@teddy:~/Documents/ruby/first-app-mysql$ rails server |
Then open on your browser: http://localhost:3000/