Passenger(Rails)とPHPを共存させる方法について伺います。
現在、さくらのVPSを借り、ウェブサービスを何とか立ち上げることができました。(hogehoge.com ドメイン取得済み)
そこで、表題の件で質問を致します。今後アクセスの増加が見込めるまで、同一VPS内にTracを積みたいと考えています。
共存させるために、調べてみるとVirtualHostというものを使うことがわかりましたが、理解しているつもりなのですができません。
目標
100.100.100.100:80 -> hogehoge.comへ飛ぶように
hogehoge.com -> hogehoge.comへ飛ぶように
100.100.100.100:8080 -> 100.100.100.100:8080/tracへ飛ぶように
#####httpd.conf
httpd.conf
1<VirtualHost *:8080> 2 ServerName 100.100.100.100:8080/trac 3 DocumentRoot /var/www/html/trac/ 4 <Directory /var/www/html/trac/> 5 PassengerEnabled Off 6 AllowOverride All 7 Options -MultiViews 8 </Directory> 9</VirtualHost>
どのようにconfは設定すればよいでしょうか。複数のサイトでは、シンボリックリンクを貼れとかいていますが、 rails_app以下にPHPが行くのは気持ち悪くまだ触れていません。シンボリックリンクを用いれば解決できますか。
追加編集について
VitualHostを利用して、Railsアプリ, PHPアプリ(独自のTracアプリ)を共存したいと考えています。
既にRailsアプリはドメイン取得済みで公開しています。(100.100.100.100:80 or www.hogehoge.comでアクセス可能)
そして、PHPアプリに関しては、これから設定をしていきたいと考えているのですが、
IPアドレス直打ちとポート8080を指定したときのみPHPアプリを公開したいと考えています。(100.100.100.100:8080)
vitualhostにどのようなことをかけばよいでしょうか。
ご回答有難うございます。私の勉強不足で、まだ解決できていません。
開発環境/conf
Server version: Apache/2.2.15 (Unix)
Server built: Oct 16 2014 14:48:21
■ httpd.conf
Listen 100.100.100.100:8080 Listen 100.100.100.100:80 NameVirtualHost 100.100.100.100:8080 NameVirtualHost 100.100.100.100:80 <VirtualHost 100.100.100.100:8080> DocumentRoot /var/www/html/trac/ ServerName 100.100.100.100:8080/trac <Directory /var/www/html/trac/> PassengerEnabled Off AllowOverride All Options -MultiViews </Directory> </VirtualHost>
■ passenger.conf
<VirtualHost *:80> ServerName www.hogehoge.com DocumentRoot /var/www/rails_app/public RailsEnv production <Directory "/var/www/rails_app/public"> AllowOverride all Options -MultiViews allow from ALL </Directory> CustomLog /var/www/rails_app/log/ ErrorLog /var/www/rails_app/log/ </VirtualHost>
■ バーチャルホストの一覧確認
[root@hagetak hagetak]# httpd -S VirtualHost configuration: 100.100.100.100:8080 is a NameVirtualHost default server 100.100.100.100:8080 (/etc/httpd/conf/httpd.conf:1004) port 8080 namevhost 100.100.100.100:8080 (/etc/httpd/conf/httpd.conf:1004) wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server hogehoge.com (/etc/httpd/conf.d/passenger.conf:25) port 80 namevhost hogehoge.com (/etc/httpd/conf.d/passenger.conf:25) Syntax OK
回答1件
あなたの回答
tips
プレビュー