PHP 版の Apache Shindig を試してみる

前もやったことある気がしますが、OpenSocial の RESTful API のサポートが追加されている?みたいなのでまたやってみます。

手元の MacBook にとりあえず apache と php をインストール。以下 zsh で auto_cd しています。

[Masahiro@masahiro.local:~] sudo port -d install php5 +apache2 +pear

apache の設定。VirtualHost の設定ファイルを読むようにして、PHP を有効に。

[Masahiro@masahiro.local:~] $ /opt/local/apache2/conf
[Masahiro@masahiro.local:/opt/local/apache2/conf] $ sudo cp httpd.conf httpd.conf.bak
[Masahiro@masahiro.local:/opt/local/apache2/conf] $ sudo vi httpd.conf
[Masahiro@masahiro.local:/opt/local/apache2/conf] $ diff -u httpd.conf.bak httpd.conf
--- httpd.conf.bak      2009-04-14 22:30:16.000000000 +0900
+++ httpd.conf  2009-04-14 22:38:59.000000000 +0900
@@ -157,7 +157,7 @@
 #
 # If your host doesn't have a registered DNS name, enter its IP address here.
 #
-#ServerName www.example.com:80
+ServerName localhost:80
 
 #
 # DocumentRoot: The directory out of which you will serve your
@@ -470,7 +470,7 @@
 #Include conf/extra/httpd-info.conf
 
 # Virtual hosts
-#Include conf/extra/httpd-vhosts.conf
+Include conf/extra/httpd-vhosts.conf
 
 # Local access to the Apache HTTP Server Manual
 #Include conf/extra/httpd-manual.conf
@@ -492,3 +492,7 @@
 SSLRandomSeed startup builtin
 SSLRandomSeed connect builtin
 </IfModule>
+
+# PHP
+LoadModule php5_module modules/libphp5.so
+Include conf/extras-conf/mod_php.conf

VirtualHost の設定。

[Masahiro@masahiro.local:/opt/local/apache2/conf] $ extra
[Masahiro@masahiro.local:/opt/local/apache2/conf/extra] $ sudo cp httpd-vhosts.conf httpd-vhosts.conf.bak
[Masahiro@masahiro.local:/opt/local/apache2/conf/extra] $ sudo vi httpd-vhosts.conf

以下の感じに編集しておきます。

Listen 8080
 
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost 127.0.0.1:8080>
    ServerName shindig.localhost
        DocumentRoot /opt/local/apache2/htdocs/shindig/php
</VirtualHost>
 
<Directory /opt/local/apache2/htdocs/shindig/php>
    AllowOverride All
</Directory>

ホスト名を shindig.localhost でアクセスするつもりなので、/etc/hosts に以下を追加しておきます。

127.0.0.1 shindig.localhost

PHP の設定。.html でも動くように。

[Masahiro@masahiro.local:/opt/local/apache2/conf/extra] $ ..
[Masahiro@masahiro.local:/opt/local/apache2/conf] $ extras-conf
[Masahiro@masahiro.local:/opt/local/apache2/conf/extras-conf] $ sudo cp mod_php.conf mod_php.conf.bak
[Masahiro@masahiro.local:/opt/local/apache2/conf/extras-conf] $ sudo vi mod_php.conf
[Masahiro@masahiro.local:/opt/local/apache2/conf/extras-conf] $ diff -u mod_php.conf.bak mod_php.conf
--- mod_php.conf.bak    2009-04-14 23:00:12.000000000 +0900
+++ mod_php.conf        2009-04-14 23:00:39.000000000 +0900
@@ -1,6 +1,6 @@
 <IfModule mod_php5.c>
 
-AddType  application/x-httpd-php         .php
+AddType  application/x-httpd-php         .html .php
 AddType  application/x-httpd-php-source  .phps
 
 </IfModule>

さて Shindig のインストール。Shindig – Building and running Shindig for PHP の通りにやります。

[Masahiro@masahiro.local:/opt/local/apache2/conf/extras-conf] $ /opt/local/apache2/htdocs
[Masahiro@masahiro.local:/opt/local/apache2/htdocs] $ sudo mkdir shindig
[Masahiro@masahiro.local:/opt/local/apache2/htdocs] $ shindig
[Masahiro@masahiro.local:/opt/local/apache2/htdocs/shindig] $ sudo svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ .

上記のページにある通り、http://shindig.localhost:8080/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml にアクセスしてみる。

Not Found
 
The requested URL /gadgets/ifr was not

なんつって怒られるときは shindig/php/.htaccess が効いていなそうなので、apache の設定の AllowOverride を確認します。

で、再度 http://shindig.localhost:8080/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml を見てみると、それっぽいモジュールが表示されるはず。

ここまではまだまだ準備段階。フー


About this entry