Fixing eAccelerator “open_basedir restriction. in Unknown on line 0″ error

If you are using PHP eAccelerator with open_basedir enabled you could have huge amount of these notices in your PHP log files:

open_basedir restriction. in Unknown on line 0

The reason behind it that at the moment eAccelerator tries to open the cached file which is usually in /var/cache/eaccelerator while open_basedir directive is still active and prevents it from doing so.

I don’t know why it is not fixed yet in the next release of eAccelerator but there is a bug about it.

Patch for v0.9.6.1 is there, but just in case, I put it on my host as well. You can download it here.

Having the patch handy, compile and install eAccelerator as usual, just patch it first:

root@video:~# cd eaccelerator-
root@video:~/eaccelerator- patch eaccelerator.c eaccelerator.c.2.patch
patching file eaccelerator.c
root@video:~/eaccelerator- phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
root@video:~/eaccelerator- ./configure
root@video:~/eaccelerator- make
root@video:~/eaccelerator- make install

Then create /etc/php5/conf.d/eaccelerator.ini:


Create cache directory

mkdir -p /var/cache/eaccelerator

Restart apache

/etc/init.d/apache2 restart

To check that it is used in CLI PHP, do

root@video:/etc/php5/conf.d# php -v
PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator

To double check it in Web, you may need to create a phpinfo file.

Tha’s it, after that you should not have any more open_basedir notices

This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

One Response to Fixing eAccelerator “open_basedir restriction. in Unknown on line 0″ error

  1. alister says:

    Thanks so much for the information and patch.
    I have been installing moodle and having had hours of trying to find the issue I found this site.

Leave a Reply

Your email address will not be published. Required fields are marked *