passenger にホストが認識されなかった
CentOS 6 に Apache+Passenger 5+Ruby 2.1 な環境構築して(その話はまたこんど書きます)たんだけど、途中で passenger-config restart-app してもホストが何も認識されてなくて「おろ?」ってなった話。要は Passenger はどのタイミングで VirtualHost が Rails アプリケーションだと理解するのか。
結論から書くと、Apache のプロセス起動したあとドメイン経由で初回アクセスした時。
ロケ地:お名前,com@VPS
どうなんの?
httpd.conf は以下のように VirtualHost が2つ書いてあるとする。
<VirtualHost *:80> DocumentRoot /var/www/sashimi.example.com/public ServerName sashimi.example.com ErrorLog logs/sashimi.example.com-error_log CustomLog logs/sashimi.example.com-access_log combined <Directory /var/www/sashimi.example.com/public> AllowOverride all Options -MultiViews -Indexes FollowSymLinks </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot /var/www/sushi.example.com/public ServerName sushi.example.com ErrorLog logs/sushi.example.com-error_log CustomLog logs/sashimi.example.com-access_log combined <Directory /var/www/sushi.example.com/public> AllowOverride all Options -MultiViews -Indexes FollowSymLinks </Directory> </VirtualHost>
この状態で Apache を起動して、即 passenger-status してみる。
[root@localhost ~]# /etc/init.d/httpd start [root@localhost ~]# passenger-status Version : 5.0.10 Date : 2015-07-16 21:44:11 +0900 Instance: 2vXicTVZ (Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 Phusion_Passenger/5.0.10) ----------- General information ----------- Max pool size : 6 App groups : 0 Processes : 0 Requests in top-level queue : 0 ----------- Application groups -----------
はい、Application groups に何も認識されてませんね。当然ですが、passenger-config restart-app で再起動させる VirtualHost 出そうとするとこうなります。
[root@localhost ~]# passenger-config restart-app Phusion Passenger is currently not serving any applications.
アクセスしてみる
ちょっと sashimi のほうだけアクセスしてからもう一度ステータスを見てみましょう。
[root@localhost ~]# wget http://sashimi.example.com/ [root@localhost ~]# passenger-status Version : 5.0.10 Date : 2015-07-16 21:49:40 +0900 Instance: 2vXicTVZ (Apache/2.2.15 (Unix) DAV/2 PHP/5.3.3 Phusion_Passenger/5.0.10) ----------- General information ----------- Max pool size : 6 App groups : 1 Processes : 1 Requests in top-level queue : 0 ----------- Application groups ----------- /var/www/sashimi.example.com: App root: /var/www/sashimi.example.com Requests in queue: 0 * PID: 31206 Sessions: 0 Processed: 2 Uptime: 14s CPU: 2% Memory : 60M Last used: 13s ago
出てきましたね。当然 restart-app の選択肢にも現れるようになりました。
[root@localhost ~]# passenger-config restart-app Please select the application to restart. Tip: re-run this command with --help to learn how to automate it. If the menu doesn't display correctly, press '!' ‣ /var/www/sashimi.example.com Cancel