Error Apache PHP Suexec FastCGI session_start open O_RDWR Permission Denied


Note to self: Fix this Error in Apache PHP Suexec FastCGI session_start open O_RDWR Permission Denied

Warning: session_start(): open(path-to-tmp-dir, O_RDWR) failed: Permission denied(13)

The solution was simple, but in most of my PHP scripts it didn’t even show this error.

The fix:

Go to your /var/tmp directory.
(or wherever you set your session temp files, probably set with session.save_path in php.ini)
Then remove all the sess_* files.
I just ran: rm -rf sess_*
I don’t know if its needed, but a reloaded Apache too.
All was working after that.

Not sure why it happened…

I got some weird errors about Zend/Session/Container  and “invalid type” errors.  All I did was copy my testing code to another server and set it up using FastCGI/Suexec in Apache.  My other server didn’t have that environment and ran Apache the normal way without FastCGI. Anyway, in the Suexec environment it didn’t show the error above till I changed my vhost config to not use FastCGI for PHP, then it finally showed me the error above which led to the simple fix.

For the record I am using FreeBSD 9.1 , Apache 2.2.x and PHP 5.3.8.