プロジェクト

全般

プロフィール

QA #812

未完了

apahce+passengerでサブディレクトリでredmineが動かない

Tamura Shinji さんがほぼ6年前に追加. ほぼ6年前に更新.

ステータス:
回答済
優先度:
通常
担当者:
-
カテゴリ:
-
対象バージョン:
-
開始日:
2018/05/30
期日:
進捗率:

0%

予定工数:

説明

http://blog.redmine.jp/articles/3_4/install/centos/
のサブディレクトリでRedmineを実行をしようとしています。

passengerは
LoadModule passenger_module /usr/local/lib/ruby/gems/2.4.0/gems/passenger-5.1.12/buildout/apache2/mod_passenger.so
が既にインストールされている環境で、単独(virtualhost)でのredmineは問題なく動作しています。

apacheのconfigには

<VirtualHost *:80>
        ServerName rd.xxxx.co.jp

        DocumentRoot "/var/www/rd" 
        Alias /hoge /var/www/redmine/site/hoge/public
        <Location /hoge>
                PassengerBaseURI /hoge
                PassengerAppRoot /var/www/redmine/site/hoge
        </Location>
        <Directory "/var/www/redmine/site/hoge/public">
          Require all granted
        </Directory>
</VirtualHost>

としている状態ですので、問題ないとおもっていたのですが。。。
passenger-statusを見ても起動はしておらず
該当ページにアクセスしても、apacheのログには

AH01276: Cannot serve directory /var/www/rd/: No matching DirectoryIndex (index.html,index.php,index.php) found, and server-generated directory index forbidden by Options directive
AH01276: Cannot serve directory /var/www/redmine/site/hoge/public/: No matching DirectoryIndex (index.html,index.php,index.php) found, and server-generated directory index forbidden by Options directive

となっている状態です。

ググっても、最新?のpassengerではできないが、5.1.12であれば動作すると書かれているのですが、
こちらも5.1.12を使っているので、なぜ動作しないものかと。。。

ちょっと行き詰ってしまったのでアドバイスいただきたく。。。

以上、よろしくお願いします

奈良 裕記 さんがほぼ6年前に更新

うーん、この辺は土地勘無く判りません。。
下記リンク二つ貼っておきますが、既にチェック済ですよね。

https://teratail.com/questions/29094

https://stackoverflow.com/questions/48207386/cannot-serve-directory-var-www-html-no-matching-directoryindex

Tamura Shinji さんがほぼ6年前に更新

はい。。。。

https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/

みても、間違っているようにも思えないんですよねぇ。。。

Tamura Shinji さんがほぼ6年前に更新

  • ステータス新規 から 回答済 に変更

apache + passenger諦めました。。。
apache + unicornに変更しました。。。
sub-URIの運用って簡単だと思ってましたが、いろいろ厄介ですね。。。

以下設定項目

"/path/to/redmine"にて

Gemfile.local

gem "unicorn" 

config.ru

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
#run RedmineApp::Application
if ENV['RAILS_RELATIVE_URL_ROOT']
  map ENV['RAILS_RELATIVE_URL_ROOT'] do
    run RedmineApp::Application
  end
else
  run RedmineApp::Application
end

config/unicorn.rb

worker_processes 2

app_path = "/var/www/redmine/site/hogehoge" 

# listen  File.expand_path('tmp/unicorn.sock', app_path)
listen  8282, :tcp_nopush => true
pid File.expand_path('tmp/unicorn.pid', app_path)
stderr_path File.expand_path('log/unicorn.stderr.log', app_path)
stdout_path File.expand_path('log/unicorn.stdout.log', app_path)

preload_app true

timeout 30

if GC.respond_to?(:copy_on_write_friendly=)
  GC.copy_on_write_friendly = true
end

before_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!

  old_pid = "#{server.config[:pid]}.oldbin" 
  if old_pid != server.pid
    begin
      sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
      Process.kill(sig, File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
    end
  end
end

after_fork do |server, worker|
  defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end

ここまでRedmineのフォルダ内
unicornをsystemdにいれる
/usr/lib/systemd/system/hogehoge-unicorn.service


Description=Redmine Marine Unicorn Server
After=mariadb.service

[Service]
WorkingDirectory=/var/www/redmine/site/hogehoge
Environment=RAILS_ENV=production
SyslogIdentifier=redmine-unicorn
PIDFile=/var/www/redmine/site/hogehoge/tmp/pids/unicorn.pid

ExecStart=/usr/local/bin/bundle exec "unicorn_rails --path /marine -c config/unicorn.rb -E production" 
ExecStop=/usr/bin/kill -QUIT $MAINPID
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target
~

apacheの設定

<VirtualHost *:80>
        ServerName xxxx.co.jp

<省略>
        ProxyPass /hogehoge http://localhost:8282/hogehoge/
        ProxyPassReverse /hogehoge http://localhost:8282/hogehoge/

</VirtualHost>

<VirtualHost *:443>
        ServerName xxxx.co.jp

<省略>
        SSLProxyEngine on

        ProxyPass /hogehoge http://localhost:8282/hogehoge/
        ProxyPassReverse /hogehoge http://localhost:8282/hogehoge/

</VirtualHost>

これだけだったかな。。。

奈良 裕記 さんがほぼ6年前に更新

お疲れ様です。

ソースは公開されているとは言え、
中をいじれるレベルにならないと、
動く環境を選択せざるを得ないのが現状。。

Tamura Shinji さんがほぼ6年前に更新

まぁ、Redmineに限らずですけどね。。。
ただ、twitterでつぶやいたらconfig/environment.rbがだめなんじゃない?という話もあるので再度チャレンジしてみます。
いまどきなら、nginx + unicornらしいですけど。。。
手動でsystemd登録とか引き継ぎ考えるとpassengerの方が楽なので。。。

他の形式にエクスポート: Atom PDF