vendredi 6 novembre 2015

Run rails application with apache and passenger on ubuntu

I have got some source code or rails project and I need to to run in on local machine. Actually on Ubuntu virtual machine.

I am not sure what all I need to install and configure in order to run it locally. Is there a standard way to find it all throughout source code?

I have figure out that application is using SQL Lite in development environment and MySQL in production environment.

from config/database.rb

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
#   gem install mysql2
#
# And be sure to use new-style password hashing:
#   http://ift.tt/1fo9lLM
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

staging:
  adapter: mysql2
  database: appname_staging
  username: rails
  password: somepassword
  host: localhost

production:
  adapter: mysql2
  database: appname_production
  username: rails
  password: somepassword
  host: localhost

Also I have set proper version of ruby and rails and install it with rvm. I know that the versions are correct because of .ruby-gemset .ruby-version files. Also I did bundle install and all gems from Gemfile installed successfully.

ruby -v => ruby 1.9.3p551 rails -v => 3.2.13

apache2 -v => Server version: Apache/2.4.7 (Ubuntu) Server built: Oct 14 2015 14:18:49

mysql -V => mysql Ver 14.14 Distrib 5.5.46, for debian-linux-gnu (i686) using readline 6.3

lsb_release -a => No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty

This is pretty much where my expertise stops. I am not sure which web server application should use. Is it predefined in source code somewhere?

I spot that there is apache, passenger and moonshine are used.

from app/manifests/application_manifest.rb

# The default_stack recipe install Rails, Apache, Passenger, the database from
  # database.yml, Postfix, Cron, logrotate and NTP. See lib/moonshine/manifest/rails.rb
  # for details. To customize, remove this recipe and specify the components you want.
  recipe :default_stack
  recipe :ssh

I also not sure what is exactly purpose of each of these individually.

How apache as web server can recognize and interpret ruby code?

I would be happy if I could host any rails app on apache. I have created some very simple app and tries these steps http://ift.tt/1NUpWW7 but it always opens default apache web page.

I am not usre where to start. I just have a bunch of questions adn a lot of confustion. I do not understand how the ROR on apache actually works.

Is the passenger the thing upon apache that interprets ruby code?

I show that nginx is alternative for passenger but it is also alternative for apache, it confuses me even more.

Thanks for any help.

Aucun commentaire:

Enregistrer un commentaire