Mac OS X で Apache Shindig を動かす。
Mac OS Xでも環境によって違うと思いますが、以下参考までに*1。
php5 用の設定を書く。
mac:php yssk22$ cat /etc/apache2/extra/httpd-php5.conf LoadModule php5_module libexec/apache2/libphp5.so <IfModule php5_module> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> </IfModule>
httpd-vhosts.conf はこんな感じで、自分一人しか使わないMacなので/Users/yssk22/Sites がなぜかDocumentRootになっていたりしますww ちなみに、passenger(a.k.a mod_rails)の設定も入っています。ポイントとしては、Shindigの方に、.htaccess で RewriteEngine の設定が書いてあるので、AllowOverride を All または FileInfo にする必要があるかと。
mac:php yssk22$ cat /etc/apache2/extra/httpd-vhosts.conf NameVirtualHost *:80 <VirtualHost *:80> ServerName mac DocumentRoot /Users/yssk22/Sites RailsBaseURI /webjourney RailsEnv development <Directory "/Users/yssk22/Sites/"> Options Indexes MultiViews FollowSymlinks AllowOverride All # <-- ここ Order allow,deny Allow from all </Directory> </VirtualHost>
httpd.conf で上記設定を読み込む
Include /private/etc/apache2/extra/httpd-php5.conf Include /private/etc/apache2/extra/httpd-vhosts.conf
$HOME/Sites (DocumentRoot) に Shinding(PHP)のソースをチェックアウト
mac:~ yssk22$ cd Sites mac:Sites yssk22$ mkdir shindig mac:Sites yssk22$ cd shindig mac:shindig yssk22$ svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ . mac:shindig yssk22$ cd php
mac:php yssk22$ cat .htaccess RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # NOTE: If you added a web_prefix to config, add it here too, e.g.: RewriteRule (.*) /shindig/php/index.php [L] # <-- ここ重要 # RewriteRule (.*) /index.php [L] # <-- / においていないので、これは意味ない。 # for OAuth signatures to work for POSTed data, always_populate_raw_data needs to be turned on php_flag always_populate_raw_post_data On
さらに shinding/php/config/contaier.php で web_prefix を /shindig/php に設定。(index.php のWeb上の相対パスがweb_prefix。自分のリクエストURIから推察できるだろうに、というのはおいといて*2。
mac:php yssk22$ cat config/container.php | grep web // The URL Prefix under which shindig lives ie if you have http://myhost.com/shindig/php set web_prefix to /shindig/php // 'web_prefix' => '', 'web_prefix' => '/shindig/php',
これで動くはずなので、http://localhost/shindig/php/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml にアクセスすると、labpixies.com のtodoガジェットが表示されます。
さらに、http://localhost/shindig/php/gadgets/files/samplecontainer/samplecontainer.html にアクセスすると、サンプルのGadget Container としてページが見られるはず、なんですが、うまくいきません。Firefox でRequestのダンプをみたら、
POST http://localhost/gadgets/metadata 404 Not Found
いやだから、web_prefix ぐらい、DRYでなんとかしろよ、という感じでやる気がなくなりました。。ちゃんとVirtualHostきって、/ に配置するのがよさそうですね。
ちなみに、Shinding のコードを見ましたが「なにこのPHPいいたかっただけちゃうんか、的な.phpのJavaコードは」という印象。昨今、PHPのJava化が急速に進行中なんですかね。