Ubuntu 14.04 ga Ruby on Rails o'rnatish

Bu qo'llanmada qanday qilib Ubuntu 14.04 ga mashhur veb freymvork Ruby on Rails ni o'rnatishni o'rganamiz. Nega Ubuntu 14.04? Chunki bu eng barqaror va LTS (long term support) ya'ni uzoq vaqt qo'llab quvvatlash. Ubuntu 14.04 2019-yilgacha qo'llab quvvatlanadi. Agar siz eski versiyada bo'lsangiz apdeyt qilishni maslahat beraman.

Ishga kirishsak. Ruby va Rails ni eng so'ngi barqaror versiyasini o'rnatishni eng oson yo'li RVM dasturi orqali amalga oshirsa bo'ladi.
Ruby ni o'rnatishdan oldin ba'zi zarur dasturlarni ornatamiz:
Terminalni ochamiz (Ctrl+Alt+T):

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
Endi RVM orqali Ruby ni o'rnatamiz:
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.1
rvm use 2.1.1 --default
ruby -v
Rails ni o'rnatamiz:
Rails juda ko'p dasturlaga qaram bo'ladi, ularsiz to'g'ri ishlashiga kafolat yo'q, shulardan biri NodeJS.
NodeJS ni o'rnatish uchun oldin repositorni qo'shamiz:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Endi Rails ni o'rnatamiz:
gem install rails

rails -v
# Rails 4.1.0
MySQL ni sozlash:
MySQL ni Ubuntu repositordan o'rnatishingiz mumkin
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
PostgreSQL ni sozlash:
PostgreSQL uchun repositor qo'shish shart
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
PostgreSQL uchun foydalanuvchi yaratilishi shart:
sudo -u postgres createuser username -s
# agar parol qo'ymoqchi bo'lsangiz
sudo -u postgres psql
postgres=# \password parol
Endi tekshirib ko'ramiz:
#### Agar MySQL dan foydalanmoqchi bo'lsangiz
rails new new_app -d mysql
 
#### Agar Postgres dan foydalanmoqchi bo'lsangiz
rails new new_app -d postgresql
 
# Dastur papkasi
cd new_app
 
# Agar MySQL yoki Postgres foydalanuvchi/parol yaratgan bo'lsangiz,
# config/database.yml falidan sozlashingiz mumkin
# Ma'lumotlar bazasi yaratamiz
rake db:create
 
rails server
Bo'ldi. Endi localhost:3000/ o'tib tekshirib ko'rishingiz mumkin.
Chiroyli dasturlash tilayman!

3 комментария

shranet
Python ni o'rganib bo'liy, keyin bunga o'tamiz :). Yaqin kelajakga bizda ham Python yoki RoR ga qiziqishib qolishsa ajab bo'lmasdi.
0
Phoenix
shranet RoR web dasturchi uchun killer app desa ham bo'ladi. RoR da sass, haml shablonizator, jquery, prototype, hammasi ichida.
0
shranet
Aha, ancha yillar oldin geniuz bilan bir ish qilgandir RoR da. Shunga ko'rgandim imkoniyatlarini.
0