Ubuntu PHP Session Error

Another quick reminder to my self, but someone out there might find it useful.

If you randomly get the following error in your php application on an Ubuntu/Debian system:-

ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) in /your/file/here on line 30

This is because PHP is attempting to clean up unused session information every now and again, and it can’t because the session storage directories permissions have been tightened on Ubuntu/Debian so that the web server cannot actually read the directory – only the files it already knows the name of.

This garbage collection would normally be disabled in Ubuntu/Debian as there is a cron job that runs every 30 mins to do the job, but if you have replaced the php.ini file with a different one, then you might have unintentionally re-enabled it.

To fix the problem, edit your php.ini file (it normally lives in /etc/php5/apache2/php.ini) and search for session.gc_probability and set it to 0. Save and restart apache and all should be well.

Posted in Web Development | Tagged , , | Leave a comment

Tang Soo Do, 8th Gup

Another graduation this weekend, and I now have a nice bright orange belt!

Orange belt and certificate

Tang Soo Do, 8th Gup

This was part of the “Positive Start” classes from McKinstry Family Martial Arts program, but I have now signed up for the full Blackbelt Leadership course which should see me collecting my Black (Midnigh Blue) belt in around 2 years.

I have been really enjoying these new classes, not only because taking up a martial art was something I have wanted to do for a few years, but because I can already see the changes in my level of fitness, and it’s a lot more enjoyable than doing the same old routine in the gym every week!

I have actually been up to other things other than the Tang Soo Do in the last two months, I have just neglected this blog a little! I’ll try and do better… Should have some big announcements between now and Christmas.

Posted in Tang Soo Do | Leave a comment

Tang Soo Do, 9th Gup

This morning I graduated my first step on the road to blackbelt leadership. I am now the owner of a 9th Gup yellow belt for Tang Soo Do.

Big thanks to McKinstry Martial Arts.

Posted in Tang Soo Do | Leave a comment

Testing Wordpress 3.0 beta 2

Just reinstalled this blog with WordPress 3.0 (beta 2) to do a bit of testing. I was very happy to see that the export and re-import worked flawlessly. During the re-import, it also went and fetched all the files and images I had attached to old posts – I thought I would have to manually copy them over!

I dont use many plugins (Google Analytics, Twitter Tools, Auto Thickbox and a Syntax Highlighter), and they all seem to be working fine.

Just need to go and hunt down some new themes – although I should probably (re)learn how-to create WordPress themes anyway!

Posted in Uncategorized | Leave a comment

iBuildings Test Driven Challenge

Fancy a shot at winning yourself an Apple iPad? Well head on over to http://ibuildings.com/challenge and have a go.

I have submitted my entry for the competition. And although they are looking for normal PHP code for the actual entries, they are giving the byte crunchers a bit of fame and glory (but not an actual entry into the contest). Which does actually make sense because we don’t really want to be promoting horrible 1 line code do we?

My crunched up entry comes in at 283 bytes. Do you think that gives me a shot at the fame and glory?

Posted in Technology | Tagged | 6 Comments

TextMate Snippets

My latest TextMate snippets that are tab completed from omap and rmap respectively should save me some  typing while I am creating my DataMappers.

\$obj->set${1/(?:^|_)([a-z0-9]+)/\u$1/gi}(\$row->${1:column_name});
$0
\$row->${1:column_name} = \$obj->get${1/(?:^|_)([a-z0-9]+)/\u$1/gi}();
$0
Posted in Web Development | Tagged , | Leave a comment

Convert AVCHD (.mts) videos on Mac OS X

This is partially a quick reminder to myself and also hopefully something that will also get picked up by google.

I was recently trying to convert some AVCHD (.mts) video files from a Panasonic Lumix camera. After much googling there didn’t seem to be much help – there were a lot of suggestions to use VLC for playback, but unfortunately the transcoding to .mp4 left a lot to be desired.

Anyway, as it turns out HandBrake does the job brilliantly.

Posted in Apple | Tagged , , , , , | Leave a comment

Big thanks and Happy New Year

After spending the best part of the last 12 months building my own business, I have become more of an entrepreneur and less of a developer.

However, I have spent the last few hours digging around in the Zend Framework again, and it just occurred to me that I fall back on the same old resources when I need a quick reminder. So a big thank you goes out to:-

  • All the people that idle around in #zftalk and #phpnw, especially Lorna and Jeremy who devote so much time to the PHP community.
  • All the people whose blogs are syndicated to phpdeveloper.org
  • And most importantly, Rob Allen for his excellent blog posts in general, and more specifically “Getting Started with Zend Framework” guide which he keeps updated very regularly.

So once again, a big thank you to you all, and everyone else in the PHP community. I hope you all have a great 2010 and I look forward to meeting more of you in person.

Posted in Web Development | Tagged , , | 1 Comment

*nix permissions reminder

After spending a while this weekend digging round with the permissions for our Ubuntu web server and local OS X development environments, I am just jotting this down as a bit of a reminder for some of the settings and useful commands.

The goals of these steps are to get OS X’s built in Apache web server running as the same group as the normal users and to update it’s umask so that when files and directories are created by the web server and by us as a user, the permissions don’t get mangled, and so we don’t have to keep using chmod!

Step 1 – Change Apache’s umask and user

Edit the /System/Library/LaunchDaemons/org.apache.httpd.plist file and add a Umask key and integer value pair. My complete plist file looks like this…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>org.apache.httpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/sbin/httpd</string>
<string>-D</string>
<string>FOREGROUND</string>
</array>
<key>OnDemand</key>
<false/>
<key>SHAuthorizationRight</key>
<string>system.preferences</string>
<key>Umask</key>
<integer>2</integer>
</dict>
</plist>

You also need to edit the /etc/apache2/httpd.conf file and find the User and Group lines and change Group to “staff”.

Don’t forget to restart Apache. Uncheck and recheck “Web Sharing” from System Preferences.

Step 2 – Change your users umask

This one is quite simple if you are using terminal for a lot of your file manipulation, just create or edit a “.profile” file in your home directory and add the following line…

umask 002

I’ll look into if/how to do this when using Finder to manage files.

Step 3 – Fix any outstanding permissions

These are some quick reminders for useful variations of commands.

Update the permissions of all files and directories in your working directory and below to be rw-rw-r– with:-

chmod -R 664 *

This will obviously break the ability to get into directories because the execute permission will have been removed, so you can reset this with a nice clever “find” command:-

find . -type d -print0 |xargs -0 chmod 775

This will restore the execute permission for the directories.

Note: On OS X I have noticed that you need to run the command repeatedly until you get no permission denied erros!
Posted in Apple, Web Development | Leave a comment

I made PHP 5.3 better!

ElePHPant vs SUSE Chamealeon

ElePHPant vs SUSE Chamealeon

The latest news on php.net is about the TestFest that took place a little while ago and how they have helped improve the code coverage – and in return, the overall stability of PHP 5.3+

Being the nerd that I am, I felt obliged to download the source and grep for my name and confirmed that 9 of my test cases from the PHPNW TestFest session have made it into PHP 5.3.

My goal is to try and keep up the good work and write more tests in the future.

Now I just have to keep my fingers crossed to see if I can win an elePHPant! (Although a SUSE lizard would be a close second!)

Posted in Web Development | Tagged , | Leave a comment