Run rails app with apache and passenger on ubuntu

I have a source code or rails project and I need to run it on a local machine. Actually on a Ubuntu virtual machine.

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

I found out that the application uses SQL Lite in the development environment and MySQL in the 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://dev.mysql.com/doc/refman/5.0/en/old-client.html
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

I also installed the correct version of rubies and rails and installed it using rvm. I know that the versions are correct because of the .ruby-gemset.ruby-version files. I also installed the package and all the gems from Gemfile were successfully installed.

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

apache2 -v = > : Apache/2.4.7 (Ubuntu)              : 14 2015 . 14:18:49

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

lsb_release -a = > LSB.                  : Ubuntu                 : Ubuntu 14.04.3 LTS                 : 14.04                 Codename: trusty

, . , - . -?

, , .

/manifestests/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

, .

apache - Ruby?

, rails apache. https://www.linode.com/docs/websites/ror/ruby-on-rails-with-apache-on-ubuntu-10-04-lucid, - apache.

. . , ROR apache.

apache, ?

, nginx , Apache, .

.

+4
3

-, , . , , , WEBRick, HTTP-, Ruby. : , , Rakefile Gemfile, :

rake db:setup # setup an sqlite database for development
rails server # start the development server

( , , SQLite sudo apt-get install sqlite3 libsqlite3-dev)

, Moonshine - . , .

Phusion Passenger " apache, - Ruby?" Apache; nginx. - (Apache, nginx ) , "" , Rails .

, Rails Apache, , . , .

Postfix - SMTP-; ( - SMTP-) Rails, , , , , , .

Cron, logrotate NTP - . Rails , . Logrotate , NTP , cron - . Moonshine , , , "" Rails.

, MySQL, MySQL; . , , ; , mysql config .yml MySQL , RAILS_ENV=production rake db:setup, . , sqlite, .

0

- . - , Apache, - - . - Ruby , , , .

, Rails , , Apache, . HTTP- "" , Rails, .

, - Apache, .

, :

$ gem install passenger -v 5.0.30
$ passenger-install-apache2-module

arent , , . , Passenger.

Apache. , , Apache , .

LoadModule passenger_module /home/devel/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/passenger-5.1.5/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
    PassengerRoot /home/devel/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/passenger-5.1.5
    PassengerDefaultRuby /home/devel/.rbenv/versions/2.4.0/bin/ruby
</IfModule>

( : , , )

, Apache, :

$ apachectl -V | grep HTTPD_ROOT
$ apachectl -V | grep SERVER_CONFIG_FILE

, . , :

<VirtualHost *:80>
  ServerName depot.yourhost.com
  DocumentRoot /home/devel/depot/public/
  SetEnv SECRET_KEY_BASE "0123456789abcdef"
  SetEnv DEPOT_DATABASE_PASSWORD "some-password"
  <Directory /home/devel/depot/public/>
    AllowOverride all
    Options -MultiViews
    Require all granted
  </Directory>
</VirtualHost>

, . cookie, .

$ bin/rails secret

SetEnv , .

- - Apache:

$ sudo apachectl restart
0

, sqlite, gem 'sqlite3' Gemfile, bundle install.

.

:

rake db:create
rake db:migrate

:

rails server
0
source

Source: https://habr.com/ru/post/1614787/


All Articles