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-0.9.6.1
root@video:~/eaccelerator-0.9.6.1# patch eaccelerator.c eaccelerator.c.2.patch
patching file eaccelerator.c
root@video:~/eaccelerator-0.9.6.1# phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
root@video:~/eaccelerator-0.9.6.1# ./configure
.........
root@video:~/eaccelerator-0.9.6.1# make
root@video:~/eaccelerator-0.9.6.1# make install

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

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/var/cache/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

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 *

*

CAPTCHA image
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">