简体   繁体   中英

How to start server running Phusion Passenger

I bought some hosting space where I have SSH access. Now I want to deploy a Ruby on Rails apps which works locally to one of the subdomains I made, let's call it subdomain.mywebsite.com.

I have setup SSH access via a public key, installed Ruby on Rails and Passenger on the server, and installed Capistrano locally by following the steps provided on the website and via tutorials. When I run cap production deploy the whole site is uploaded to the production server and via SSH I can see the current, releases, repo and shared folder. Unfortunately, when I go to subdomain.mywebsite.com I get a 404 - not found error.

I am new to setting up my own server and do not know what to do now. All tutorials I have found do not explain how to continue from here, and I hope someone who reads this can help me to actually being able to access the site.

Deploy.rb:

require 'capistrano'
set :stages, ["staging", "production"]
set :default_stage, "staging"
set :application, 'chiachia_store' # application name
set :repo_url, 'git@github.com:erooijak/chiachia_store.git' # your repo url
set :deploy_to, '/home/erooijak/chiachia.erooijak.simple-webhosting.eu'
set :user, "root"
set :scm, :git
set :branch, 'master'
set :keep_releases, 5
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }
set :format, :pretty
set :log_level, :debug
set :pty, true
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
set :stage, :production
role :app, %w{root@213.159.6.126}
role :web, %w{root@213.159.6.126}
role :db, %w{root@213.159.6.126}
set :puma_rackup, -> { File.join(current_path, 'config.ru') }
set :puma_state, "#{shared_path}/tmp/pids/puma.state"
namespace :deploy do

desc 'Restart application...'
task :restart do
  on roles(:app), in: :sequence, wait: 5 do
    # Your restart mechanism here, for example:
    execute :touch, release_path.join('tmp/restart.txt')
  end
 end

 desc 'Copy database.yml to correct location.'
 task :copy_databaseyml do
   on roles(:app) do
     execute :cp ,'-r', shared_path.join('config/database.yml'), 
       release_path.join('config/database.yml')
   end
 end

after :publishing, :restart

after :restart, :copy_databaseyml
end

Apache.conf:

LoadModule passenger_module /usr/lib/apache2/modules/mod_passenger.so PassengerRoot /usr/local/rvm/gems/ruby-1.9.3-p547/gems/passenger-4.0.49 PassengerRuby /usr/bin/ruby

  ServerName www.chiachia.erooijak.simple-webhosting.eu
  # !!! Be sure to point DocumentRoot to 'public'!
  DocumentRoot /home/erooijak/chiachia.erooijak.simple-webhosting.eu/current/public
  <Directory /home/erooijak/chiachia.erooijak.simple-webhosting.eu/current/public>
     # This relaxes Apache security settings.
     AllowOverride all
     # MultiViews must be turned off.
     Options -MultiViews
     # Uncomment this if you're on Apache >= 2.4
     #Require all granted
  </Directory>
</VirtualHost>

The effect of running this is the following:

Apache Passenger正在运行...

So it kind of works. Unfortunately I get a 404 error on all domains, the PHP application keeps running properly.

The passenger.3000.log has the following information:

Why don't we start from scratch.

After reading your last comments, what you want is to be able to deploy multiple rails applications on the same server.

There are many options to do that, and depending on what you choose, configuration is going to be very different. There is a good SO answer that covers the basics you might want to read:

Ruby on Rails Server options

The stack I'm used to is Nginx/capistrano/unicorn but that depends on personal preferences and the nature of what's deployed.

Apache/Phusion passenger

The first thing to do is to configure apache for your domain. The phusion passenger documentation is a very good starting point.

You can even find a complete guide on how to deploy Rails >= 3.X apps with phusion passenger in the same documentation

If you follow carefully the instructions, you should have your app up and running without puma. They even also provide you capistrano recipes to use.

Puma

At this stage, unless you app needs high concurrency, puma is not needed. Phusion Passenger is an app server by itself, no need to add puma behind it. If you really need it for some reason, then you'll be better off switching to Nginx/Puma.

I hope the references I gave you clear things up a bit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM