Table of Contents
New installation Ruby, NodeJS & Rails
Another source link: http://www.gotealeaf.com/blog/how-to-install-ruby-on-rails-development-environment-for-linux
Install Ruby on Ubuntu using rbenv
https://gorails.com/setup/ubuntu/14.04
sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties cd git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL rbenv install 2.1.3 rbenv global 2.1.3 ruby -v
The last step is to tell Rubygems not to install the documentation for each package locally
echo "gem: --no-ri --no-rdoc" > ~/.gemrc
Configuring GIT
git config --global color.ui true git config --global user.name "Alfredo" git config --global user.email "alfredo.roca.mas@gmail.com" ssh-keygen -t rsa -C "alfredo.roca.mas@gmail.com"
The next step is to take the newly generated SSH key and add it to your Github account. You want to copy and paste the output of the following command and paste it here.
cat ~/.ssh/id_rsa.pub
Once you've done this, you can check and see if it worked:
ssh -T git@github.com
You should get a message like this:
Hi excid3! You've successfully authenticated, but GitHub does not provide shell access.
Installing NodeJS & Rails
sudo add-apt-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs gem install rails
If you're using rbenv, you'll need to run the following command to make the rails executable available:
rbenv rehash
Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:
rails -v # Rails 4.1.8 o similar
Setting Up PostgreSQL
For PostgreSQL, we're going to add a new repository to easily install a recent version of Postgres 9.3.
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list" wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get install postgresql-common sudo apt-get install postgresql-9.3 libpq-dev
The postgres installation doesn't setup a user for you, so you'll need to follow these steps to create a user with permission to create databases.
sudo -u postgres createuser alfredo -s
# If you would like to set a password for the user, you can do the following
sudo -u postgres psql postgres=# \password alfredo
Final Steps :: check the installation
And now for the moment of truth. Let's create your first Rails application:
#### If you want to use Postgres
# Note that this will expect a postgres user with the same username
# as your app, you may need to edit config/database.yml to match the
# user you created earlier
rails new myapp -d postgresql
# Move into the application directory
cd myapp
# If you setup MySQL or Postgres with a username/password, modify the
# config/database.yml file to contain the username/password that you specified
# Create the database
rake db:create rails server
Issue on installing node&npm as sudo and other packages with no sudo
http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
It's safer to create a new group for node-users and add the required users to this group, further to set the ownership of node-dependant files/directories to this group.
# Create new group
sudo groupadd nodegrp
# Add user to group (logname is a variable and gets replaced by the currently logged in user)
sudo usermod -a -G nodegrp `logname`
# Instant access to group without re-login
newgrp nodegrp
# Check group - nodegrp should be listed as well now
groups
# Change group of node_modules, node, npm to new group
sudo chgrp -R nodegrp /usr/lib/node_modules/ sudo chgrp -R nodegrp /usr/lib/nodejs sudo chgrp nodegrp /usr/bin/node sudo chgrp nodegrp /usr/bin/npm
# (You may want to change a couple of more files (like grunt etc) in your /usr/bin/ directory.)
Now you can easily install your modules as user
npm install -g generator-angular
Some modules (grunt, bower, yo etc.) will still need to be installed as root. This is because they create symlinks in /user/bin/.
More about PostgreSQL
basename=# SELECT * FROM tabla;
SHOW TABLES basename=# \d
SHOW DATABASES basename=# \l
SHOW COLUMNS basename=# \d table
DESCRIBE TABLE basename=# \d+ table
\du lista los usuarios de postgres y sus propiedades
createuser -P -s -d -r -e zabbix crea el usuario zabbix con privilegios de root
psql -h localhost -U zabbix zabbix entramos en Postgres, con el usuario zabbix a la base de datos zabbix
Conectar a base de datos # \c basename
Cómo revisar si PostgreSQL está funcionando: $ /etc/init.d/postgresql status Password:
==> pg_ctl: server is running (PID: 6171)
Salir # \q
Rails app file :: database.yml
development:
adapter: postgresql encoding: unicode database: myapp_development pool: 5 username: alfredo password: oderfla
test:
adapter: postgresql encoding: unicode database: myapp_test pool: 5 username: alfredo password: oderfla
Create the databases
$ rake db:create:all