问题
I am deploying my first rails application. I have some trouble doing that. I will describe what I did till now.
1) I configured everything correctly by going through gorails.com
2) I am trying to deploy it on Digital Ocean
3) I performed cap deploy production
and the end result was successful with some failures in middle.
4) I started nginx server
5) In my browser it gave me 500 error.
6) I checked my production.log
and it showed all the migrations and seeds that it ran. It created tables perfectly (As I checked in my db too).
7) I checked nginx error.log
and it showed that index.html is missing.
8) So in order to check, I added index.html file in public directory and browser displayed the content correctly.
9) But my landing page is index.html.erb in home controller, so in routes file I have done some modifications but no change in the output in browser.
10) And I have noticed that error.log and production.log are not updating instantly. I dont know why.
11) I need help in making nginx display my index.html.erb file and connecting it with rails app. Database is configured correctly.
12) My nginx config file is :
server {
listen 80 default_server;
server_name digital_ocean_ip;
passenger_enabled on;
rails_env production;
root /home/myapp/myapp/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Here my user name and my application names are same so (/myapp/myapp)
13) My routes.rb file is :
Rails.application.routes.draw do
root "public#index"
get 'access/logout'
get '/signup' => "users#signup"
get '/register' => "users#signup"
get '/login' => "access#login"
get '/' => "home#index"
resources :users do
member do
get :confirm_email
end
collection do
post :search
end
end
resources :books do
collection do
get :recent
get :academic
get :novels
get :preparation
end
end
resources :password_resets
match '/users/show' => 'users#books', :via=> :get
match ':controller(/:action(/:id))', :via => [:get,:post]
get '*path' => redirect('404')
end
14) My deploy.rb file is:
lock '3.4.0'
set :application, 'myapp'
set :repo_url, 'git@github.com:user_name/myapp.git'
set :deploy_to, '/home/myapp/myapp'
role :app, %w{Digitalocean_ip}
role :web, %w{Digitalocean_ip}
role :db, %w{Digitalocean_ip}
set :linked_files, %w{config/database.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :linked_dirs, fetch(:linked_dirs) + %w{public/uploads}
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile config/routes.rb)
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
desc 'Runs rake db:seed'
task :seed => [:set_rails_env] do
on primary fetch(:migration_role) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, "db:seed"
end
end
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
15) My production.rb file is:
set :stage, :production
server 'Digitalocean_ip', user: 'myapp', roles: %w{web app db}
16) These are all my config files. Please tell me where its going wrong
Thanks in advance!
来源:https://stackoverflow.com/questions/36482125/deployment-of-rails-app-using-nginx-passenger-and-capistrano