Apache Shindig PHP Setup Problem Solved

First things first. Shindig is an Apache incubator project that serves as an OpenSocial Container and…I’m already falling asleep. Too boring. I’m way behind the curve on all things “social networking” but I have an idea for an app that may scratch an itch I have, and it just happens that some of this social networking stuff might be a good way to jump start the idea. So that means catching up on a couple of years (or more) of stuff that’s been going in the world of web 2.0, which includes OpenSocial. I wanted a local OpenSocial test sandbox and found Shindig to fit that bill.

Now, onto the problem I was running into and the solution. Unless you want the long boring details, I can save you the trouble and tell you to make sure you have mod_rewrite enabled in Apache.

If you haven’t dozed off by now then it probably means you’re running into issues with the Shindig PHP setup and would like some more details. I followed the directions on setting up the PHP Shindig server on my laptop running Kubuntu 08.04 here at home and kept getting a 404 error. I thought that was strange since I could hit other files with my browser that I put in that directory manually for testing but not the Shindig index.php page. Turns out the Shindig index.php page tries to be more “controller/servlet” like by sniffing the URI and passing it along to the appropriate handler. If it can’t find a match, then it gives a custom 404 error. I noticed the test URI (http://shindig/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml) didn’t have any reference to index.php. Ah yes, the wonders of Apache mod_rewrite! And guess what I didn’t have enabled? Yep, Apache mod_rewrite. So, below is what I did to get things running on an Ubuntu setup from scratch (meaning no Apache 2, PHP 5 was installed or configured):

sudo apt-get install apache2 apache2-common apache2-mpm-prefork apache2-utils ssl-cert libapache2-mod-php5 php5-cli php5-common php5-curl php5-mcrypt

svn co http://svn.apache.org/repos/asf/incubator/shindig/trunk/ /home/jhoover/dev/shindig

sudo mv /etc/apache2/mods-available/rewrite.load  /etc/apache2/mods-enabled/

sudo cp /etc/apache2/sites-enabled/000-default /etc/apache2/sites-enabled/shindig

sudo pico /etc/apache2/sites-enabled/shindig

Stop laughing, I use the Pico text editor. I’m, as my son would say, “weak sauce”. I know. Anyway, here’s what I have in that virtual host file:

NameVirtualHost *
<VirtualHost 127.0.0.1:80>
  ServerAdmin webmaster@localhost
  ServerName shindig

  DocumentRoot /home/jhoover/dev/shindig/php
  DirectoryIndex index.html index.php
  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>

  ErrorLog /var/log/apache2/error.log
  LogLevel warn

  CustomLog /var/log/apache2/access.log combined
  ServerSignature On
</VirtualHost>

Once we have that in place, we need to edit our host file:

sudo pico /etc/hosts

Append the following to the hosts file and save:

127.0.0.1       shindig

Time to restart Apache:

sudo /etc/init.d/apache2 restart

Now you should be able to go to your web browser of choice and run the demo/test app:

http://shindig/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml

If all went well you should see something a little like this:

  • Japi

    YOu really should consider moving this to de Ubuntu wiki. Really helpful stuff

  • Jeroen

    Thanks, this helped me

    In addition, I needed the help of
    http://blog.taragana.com/index.php/archive/mod_rewrite-not-working-in-htaccess-solution/

    I had Apache mod_rewrite enabled, but it wasn’t kicking in because somewhere an ‘AllowOverride None’ blocked the inclusion of my .htaccess (and initially the .htaccess didn’t unzip along).

    So the recipe for success:
    1) make sure you have mod_rewrite enabled if you get a blank ‘404 not found’ page (which is generated by Shindig itself – they could have added a comment stating this…)

    2) make sure mod_rewrite is invoked, you can check this by enabling its debug log in httpd.conf

    3) If needed, edit config/container.php to set the correct prefix

  • K Suresh

    Really nice blog. It really help to come up with my problem which i am facing from last two days.

    Thanks dude!!!

  • Sean

    Thanks, that really helped.
    Also, your photograph awkwardly reminds me of Dieter Bohlen.