Enable PHP on BigBlueButton .71 Server

2010/12/18 8 comments

It’s been asked a couple times how to run PHP on a BigBlueButton (BBB) server. The following has been tested on the .71 BBB virtual image.

BBB uses nginx to route incoming web traffic red5, tomcat and some other stuff. Because of that, you can’t use any urls that start with /bigbluebutton, /deskshare, /client, /open/, /close, /idle/, /send/. But we can install php and enable it for other urls.

First we need to install php5-fpm. It’s not included in the ubuntu 10.04 php packages, so we’ll use a PPA for it.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:brianmercer/php
sudo apt-get update
sudo apt-get install php5-fpm

Open /etc/php5/fpm/php5-fpm.conf with your favorite editor and find the line that starts with listen, and edit to this:

listen = /var/run/php5-fpm.socket

Now we need to tweak the nginx site config file vim /etc/nginx/sites-enabled/bigbluebutton. At the end – but before the last } – we need to add the following block of code:

 location ~ .php$ {
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_pass   unix:/var/run/php5-fpm.socket;
    fastcgi_param  SCRIPT_FILENAME  /var/www/bigbluebutton-default$fastcgi_script_name;
    include /etc/nginx/fastcgi_params;
    fastcgi_index index.php;
  }

This is optional, but if you may want to find the block that starts with location / { and add index.php to the list of indexes. This will allow you to use index.php if you use a url to a directory with no explicit filename.

Now restart php5-fpm:

sudo /etc/init.d/php5-fpm restart

And restart nginx:

sudo /etc/init.d/nginx restart

Let’s test it out. Create a file /var/www/bigbluebutton-default/test.php with this:

<?php phpinfo(); ?>

Then test it by going to http://<ip>/test.php.

Now you can install any other php packages you may need for whatever you want to do – like php5-mysql…

You’ll need to run /etc/init.d/php5-fpm restart after installing php packages.

Ignore Git files that already exist in the repository

2010/11/10 Leave a comment

I made changes to some config files for dev purposes. And I didn’t want to commit that back into git. The problem is that .gitignore and .git/info/exclude don’t work on a file already in the repository. So after googling a bit, I found a way to do this here: http://justaddwater.dk/2009/12/07/how-to-make-git-ignore-files-that-already-exist-in-your-project/

And here’s the command from that link:

git update-index --assume-unchanged config/database.yml

Of course you won’t be able to update that file until you do:

git update-index --no-assume-unchanged config/database.yml

The doc on this command is here: http://www.kernel.org/pub/software/scm/git/docs/git-update-index.html

Categories: git Tags:

Set up nginx and php-fpm to run symfony

2010/10/14 Leave a comment

I wanted to set up a generic nginx configuration for my symfony development environment. The way my dev box is set up, I have symlinks in /var/www to the web directory of each of my projects. That way I can access them like http://localhost/project1/frontend_dev.php/, etc.

This isn’t so hard to set up on ubuntu 10.10. Just install nginx and php-fpm with apt-get. I made one little tweak to php-fpm, I configured it to use a unix socket instead of a local port.

Open /etc/php5/fpm/pool.d/www.conf with your favorite editor and edit the listen line to this:

listen = /var/run/php-fpm.socket

Then tweak the nginx site config file vim /etc/nginx/sites-enabled/default, this is what I got working for me:

server {
  listen       80;
  root /var/www/;
  index  index.php,index.html,index.htm;
  autoindex on;

  charset utf-8;

  location / {
    # If the file exists as a static file serve it directly without
    # running all the other rewite tests on it
    if (-f $request_filename) {
      expires 1m;
      break;
    }
#    if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
#      rewrite ^(.*) /index.php last;
#    }
  }
 location ~ \.php($|/) {
    set  $script      $uri;
    set  $path_info   "";

    if ($uri ~ "^(.+\.php)($|/)") {
      set $script $1;
    }
    if ($uri ~ "^(.+\.php)(/.+)") {
      set  $script     $1;
      set  $path_info  $2;
    }

    fastcgi_pass   unix:/var/run/php-fpm.socket;

    include /etc/nginx/fastcgi_params;

    fastcgi_param  SCRIPT_NAME      $script;
    fastcgi_param  SCRIPT_FILENAME  /var/www$script;
    fastcgi_param  PATH_INFO        $path_info;
  }
}

I still haven’t gotten it to work with automatically adding index.php. (That part is commented out in the nginx config above.) I think it’s because I’ve kept it generic to serve all kinds of files and multiple symfony apps – not just one symfony app. So it would probably need some work for production (there’ll probably be a virtual host on production anyway). But I use frontend_dev.php, etc for all my development.

Categories: nginx, symfony Tags: , , ,

Changing Aptana 3’s Default Workspace

2010/10/13 8 comments

Aptana 3 locks eclipse’s workspace to ~/Aptana 3 Workspace. Aptana does let you change it after starting Aptana, but it will always load the above workspace when it starts. Here’s how to change that to always load a different workspace at startup.

Go to the directory where the Aptana binary is, and edit configuration/config.ini, and change the line that looks like this to whatever you want:

osgi.instance.area.default=@user.home/Aptana 3 Workspace

This was found here, which also shows you how to move your rubles: http://danielsmedegaardbuus.dk/2010-08-31/be-gone-stupid-aptana-studio-3-folders-in-my-home-directory/

Categories: aptana Tags: ,

Clickable rows in jQuery

2010/10/13 Leave a comment

Found a nice post about making the entire <tr> clickable using jQuery. http://imar.spaanjaars.com/549/how-do-i-make-a-full-table-row-clickable-using-jquery It pulls the link from the <a> tag in the first column. But I made a couple modifications to it to my liking, posted here.
The html code:

<table>
  <thead>
    <tr>
      <th>Id</th>
      <th>Name</th>
    </tr>
  </thead>
  <tbody class="row_clickable">
    <tr>
      <td><a href="edit/1">1</td>
      <td>First Item</td>
    </tr>
    <tr>
      <td><a href="edit/2">2</td>
      <td>Second Item</td>
    </tr>
  </tbody>
</table>

This jQuery below will use the first <a> in the first <td> for the link. And if you want to optionally hide that column at the same time, you can add the class hide_link to the <tbody>.

  <tbody class="row_clickable hide_link">

Here’s the jQuery:

$(function(){
  // clickable rows on tables
  $('.row_clickable.hide_link tr td:first-child, '+
    '.row_clickable.hide_link tr th:first-child').hide();
  $('.row_clickable tr').hover(function(){
    $(this).toggleClass('highlight');
  });
  $('.row_clickable tr').click(function(){
    location.href = $(this).find('td a').attr('href');
  });});

And a little css:

.row_clickable tr{
  cursor:pointer;
}
.row_clickable tr.highlight,
.row_clickable tr.highlight td,
.row_clickable tr.highlight th{
  background-color:#ee9;
}
Categories: html, jquery Tags: , , , ,