I've installed Debian 6.0.6 x86 on a VPC with the least possible software packages and when the installation completes I take a backup of the VPC and put it aside for later use.

I have installed PHP 5 via aptitude install php5 and create a PHP script file with the following content and call it test.php:

    if ( function_exists("chroot") ) {
    echo "Function works !\n";
    } else {
    echo "Function does NOT work !\n";

When I run the script via command line php -f test.php it shows me Function works ! Everything fine so far.

Since the PHP version within the php5 package is pretty old I would like to compile my own version - currently 5.4.13 - so I restore my back-upped VPC image and compile it with the following parameters:


Output shows me:

Running system checks
checking for chroot... yes

And the compile, make and make install completes flawlessly.

When I recreate and run the test.php script now I get the message Function does NOT work !.

What is going on here I ask myself, am i running the script the wrong way since the documentation says the following: This function is only available to GNU and BSD systems, and only when using the CLI, CGI or Embed SAPI. Also, this function requires root privileges. or is there something not configured correctly ?


The reason why i try to get this chroot function to work is because i want to install Symfony2. When i run php composer.phar create-project symfony/framework-standard-edition /var/www/symfony2 from within the /root folder it throws me an error:

PHP Fatal error: require_once(): Failed opening required 'app/autoload.php' (include_path='.:/usr/local/lib/php') in /var/www/symfony2/vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php on line 24

However when i install the php5 package via the apt-get manager and run the same composer command it works perfectly. With the precompiled deb php5 package the script changes the current working directory to /var/www/symfony2 while my compiled php binary doesn't (i think). Then i figured out my php version doesn't have any chroot function so i thought this could be the culprit.

  • I believe this question may be better on another stack since it seems a little off topic and more server technically involved. I've voted for it to be moved to server fault, hopefully if others vote it across you should get some useful help. – Simon Hayter Mar 24 '13 at 12:42
  • It's ok for me to move this topic. Don't know if this is a server related problem or a misconfiguration somewhere so i decided to put my question here :) – JonasVH Mar 24 '13 at 16:24
  • @JonasVH: It's better that you let the mods move the question, rather than double-posting - if that is what you are implying? A question migration also benefits from any additional traffic from this end, which wouldn't happen if it was simply deleted and re-asked at the other site. – MrWhite Mar 24 '13 at 16:38
  • How did you set up PHP? – Michael Hampton Mar 25 '13 at 2:37
  • @MichaelHampton After the installation i just copy the provided ini file to the proper location like so: cp /root/php-5.4.13/php.ini-development /etc/php/php.ini – JonasVH Mar 25 '13 at 9:12

Have you prepared a proper chroot for PHP to chroot into?

Simply setting an arbitrary directory is not enough - you actually need to build the chroot and ensure it includes all necessary libraries, devices and binaries.

Otherwise, basic things like DNS resolution will fail to work and you'll get random errors, hangs or app segfaults. It sounds like you are mistaking the simplicity of open_basedir with that of a chroot.

As a start, this script, once customized, should give you a basis for a chroot.


Dotdeb already includes pre-compiled binaries for PHP

The Dotdeb repo keeps up-to-date pre-compiled builds of the latest versions of PHP - and would be considerably easier and quicker to implement.



First off, chroot() is NOT the solution to your problem. Please gain a thorough understanding of what chroot() is, and what it does before attempting to use it, or you will make yourself miserable for no good reason.

What you need to do to solve your problem is set the paths PHP looks under for require'd files (the include path). There is a function for that, or you can set it in php.ini.
Alternatively, run your Symfony setup scripts *from the root directory of the Symfony installation (where you extracted the framework too) which is what you're expected to do...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.