質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

Q&A

解決済

1回答

1235閲覧

capistranoでrailsのデプロイをしたはずがcurrentディレクトリの最新のソースがサイトアクセス時にrenderされません。

traveler18

総合スコア6

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

rbenv

rbenvは、Rubyバージョン管理ツール。プロジェクトごとでRubyバージョンを切り替えることが可能です。RVMよりもシンプルで、少ない機能で動作します。本体にはRubyのビルド機能は備わっておらず、ruby-buildというツールを用いる必要があります。

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

Capistrano

Rubyで書かれたサーバオーケストレーションで、複数のサーバでスクリプトを実行する際に用いられます。主な使用用途はWebアプリケーションのデプロイメントです。 アプリケーションのバージョンアップ自動化、およびデータベースの変更などもできます。

0グッド

0クリップ

投稿2018/05/03 06:43

編集2018/06/08 11:37

前提・実現したいこと

ruby on railsでwebサイトを作っています。
capistranoで本番環境へのデプロイを自動化しようとしたのですが、
反映がされず(currentディレクトリのファイルではなく、documentroot直下の古いソースコード)前のバージョンのファイルが画面に出力表示されます。

currentディレクトリには最新のソースコードが反映されていることを確認済みです。
下記がapacheの設定ファイルの内容です。

vi /etc/httpd/conf/httpd.conf

LoadModule passenger_module /usr/lib64/httpd/modules/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /usr/share/ruby/vendor_ruby/phusion_passenger/locations.ini PassengerDefaultRuby /home/vpslunch/.rbenv/versions/2.4.3/bin/ruby PassengerInstanceRegistryDir /var/run/passenger-instreg </IfModule> <VirtualHost *:80> ServerName ***.***.**.*** # Tell Apache and Passenger where your app's 'public' directory is #DocumentRoot /var/www/html/lunchfriends/public/ #DocumentRoot /var/www/html/lunchfriends/ DocumentRoot /var/www/html/lunchfriends/current #DocumentRoot /var/www/html/lunchfriends/current/public PassengerRuby /home/vpslunch/.rbenv/versions/2.4.3/bin/ruby # Relax Apache security settings #<Directory /var/www/html/lunchfriends/public/> #<Directory /var/www/html/lunchfriends/> #<Directory /var/www/html/lunchfriends/current/public> <Directory /var/www/html/lunchfriends/current> Allow from all Options -MultiViews # Uncomment this if you're on Apache > 2.4: Require all granted </Directory> RewriteEngine on RewriteCond %{SERVER_NAME} =***.***.**.*** [OR] RewriteCond %{SERVER_NAME} =***.***.**.*** RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>

config/deploy/production.rb

# server-based syntax # ====================== # Defines a single server with a list of roles and multiple properties. # You can define all roles on a single server, or split them: # server "example.com", user: "deploy", roles: %w{app db web}, my_property: :my_value # server "example.com", user: "deploy", roles: %w{app web}, other_property: :other_value # server "db.example.com", user: "deploy", roles: %w{db} # role-based syntax # ================== # Defines a role with one or multiple servers. The primary server in each # group is considered to be the first unless any hosts have the primary # property set. Specify the username and a domain or IP for the server. # Don't use `:all`, it's a meta role. role :app, %w{vpslunch@***.***} role :web, %w{vpslunch@***.***} role :db, %w{vpslunch@***.***} # Configuration # ============= # You can set any configuration variable like in config/deploy.rb # These variables are then only loaded and set in this stage. # For available Capistrano configuration variables see the documentation page. # http://capistranorb.com/documentation/getting-started/configuration/ # Feel free to add new variables to customise your setup. # Custom SSH Options # ================== # You may pass any option but keep in mind that net/ssh understands a # limited set of options, consult the Net::SSH documentation. # http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start # # Global options # -------------- set :ssh_options, { port: 22, keys: ['~/.ssh/id_rsa'], forward_agent: true, } set :deploy_target, 'app' set :branch, :master # # The server-based syntax can be used to override options: # ------------------------------------ # server "example.com", # user: "user_name", # roles: %w{web app}, # ssh_options: { # user: "user_name", # overrides user setting above # keys: %w(/home/user_name/.ssh/id_rsa), # forward_agent: false, # auth_methods: %w(publickey password) # # password: "please use keys" # }

config/deploy.rb

# config valid only for current version of Capistrano # lock '3.3.5' set :application, 'lunchfriends' # set :repo_url, '****' set :repo_url, ' ***' # set :repo_url, '***' # Default branch is :master # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call # Default deploy_to directory is /var/www/my_app_name set :deploy_to, '/var/www/html/lunchfriends' set :user, "vpslunch" # Default value for :scm is :git # set :scm, :git # set rbenv set :rbenv_type, :user # or :system, depends on your rbenv setup set :rbenv_ruby, '2.4.3' # Default value for :format is :pretty # set :format, :pretty # Default value for :log_level is :debug # set :log_level, :debug # Default value for :pty is false # set :pty, true # Default value for :linked_files is [] set :linked_files, fetch(:linked_files, []).push('config/database.yml') set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system', 'public/uploads') # Default value for default_env is {} # set :default_env, { path: "/opt/ruby/bin:$PATH" } # Default value for keep_releases is 5 # set :keep_releases, 5 namespace :deploy do after :restart, :clear_cache do on roles(:web), in: :groups, limit: 3, wait: 10 do # Here we can do anything such as: # within release_path do # execute :rake, 'cache:clear' # end end end end

Capifile

# Load DSL and set up stages require "capistrano/setup" # Include default deployment tasks require "capistrano/deploy" # Load the SCM plugin appropriate to your project: # # require "capistrano/scm/hg" # install_plugin Capistrano::SCM::Hg # or # require "capistrano/scm/svn" # install_plugin Capistrano::SCM::Svn # or require "capistrano/scm/git" install_plugin Capistrano::SCM::Git # Include tasks from other gems included in your Gemfile # # For documentation on these, see for example: # # https://github.com/capistrano/rvm # https://github.com/capistrano/rbenv # https://github.com/capistrano/chruby # https://github.com/capistrano/bundler # https://github.com/capistrano/rails # https://github.com/capistrano/passenger # # require "capistrano/rvm" require "capistrano/rbenv" # require "capistrano/chruby" require "capistrano/bundler" require "capistrano/rails/assets" require "capistrano/rails/migrations" require "capistrano/passenger" # Load custom tasks from `lib/capistrano/tasks` if you have any defined Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }

apacheのエラーログ vi /var/log/httpd/error_log

App 7521 stdout: App 7521 stderr: [passenger_native_support.so] not found for current Ruby interpreter. App 7521 stderr: This library provides various optimized routines that make App 7521 stderr: Phusion Passenger faster. Please run 'sudo yum install passenger-devel-5.2.3' App 7521 stderr: so that Phusion Passenger can compile one on the next run. App 7521 stderr: [passenger_native_support.so] finding downloads for the current Ruby interpreter... App 7521 stderr: (set PASSENGER_DOWNLOAD_NATIVE_SUPPORT_BINARY=0 to disable) App 7521 stderr: Could not download https://oss-binaries.phusionpassenger.com/binaries/passenger/by_release/5.2.3/rubyext-ruby-2.4.3-x86_64-linux.tar.gz: The requested URL returned error: 404 Not Found App 7521 stderr: Trying next mirror... App 7521 stderr: Could not download https://s3.amazonaws.com/phusion-passenger/binaries/passenger/by_release/5.2.3/rubyext-ruby-2.4.3-x86_64-linux.tar.gz: The requested URL returned error: 403 Forbidden App 7521 stderr: [passenger_native_support.so] will not be used (can't compile or download) App 7521 stderr: --> Passenger will still operate normally. App 7614 stdout: App 7614 stdout: 128

試したこと

https://www.phusionpassenger.com/library/walkthroughs/deploy/ruby/ownserver/apache/oss/el7/install_passenger.html
1:上の公式サイトを参考にpassengerをインストール

2: https://www.phusionpassenger.com/library/deploy/apache/automating_app_updates/ruby/
上の公式サイトを参考にして、 capistranoをインストールしてページの最後の箇所の

bundle exec cap production deploy

を実行して、 currentディレクトリに最新のソースコードをgithubからpull。asset compile
やapache, pasengerのrestartなどを実行。

apache, passengerの実行状況

# sudo /usr/sbin/passenger-memory-stats Version: 5.2.3 Date : 2018-05-03 16:47:20 +0900 --------- Apache processes --------- PID PPID VMSize Private Name ------------------------------------ 7468 1 314.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7507 7468 316.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7508 7468 316.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7509 7468 316.9 MB 0.5 MB /usr/sbin/httpd -DFOREGROUND 7512 7468 316.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7513 7468 316.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7595 7468 316.9 MB 0.4 MB /usr/sbin/httpd -DFOREGROUND 7601 7468 316.9 MB 0.3 MB /usr/sbin/httpd -DFOREGROUND 7602 7468 316.9 MB 0.2 MB /usr/sbin/httpd -DFOREGROUND 7603 7468 316.9 MB 0.3 MB /usr/sbin/httpd -DFOREGROUND 7604 7468 316.9 MB 0.3 MB /usr/sbin/httpd -DFOREGROUND ### Processes: 11 ### Total private dirty RSS: 3.84 MB -------- Nginx processes -------- ### Processes: 0 ### Total private dirty RSS: 0.00 MB ----- Passenger processes ----- PID VMSize Private Name ------------------------------- 7491 354.8 MB 2.1 MB Passenger watchdog 7498 1054.1 MB 4.9 MB Passenger core 7614 381.1 MB 87.1 MB Passenger RubyApp: /var/www/html/lunchfriends (production) ### Processes: 3 ### Total private dirty RSS: 94.07 MB

環境情報(FW/ツールのバージョンなど)

CentOS Linux release 7.4.1708 (Core) (さくらvps)
ruby: 2.4.3(rbenv)
rbenv 1.1.1-28-gb943955
rails 5.0.6
Phusion Passenger 5.2.3
Apache/2.4.6 (CentOS)
Capistrano 3.3.5

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

一旦OSを再インストールして環境構築をやりなおしました。
おそらく原因として、以下のうちのいずれか、または複数の組み合わせだろうと考えました。
ありがとうございました!!
・passengerの設定ファイルが壊れていた、
・またはapacheとpassengerの連携ができていなかった
・gemと yumでインストールした二つのpassengerが競合していて起動していなかった

↓ Githubに手順書を作成したのでこちらを参照してください。
https://github.com/katsuharu/Rails_deploy/blob/master/README.md

投稿2018/06/12 15:05

traveler18

総合スコア6

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問