Chroot doesn't work in PHP5-FPM + nginx The 2019 Stack Overflow Developer Survey Results Are...

Why didn't the Event Horizon Telescope team mention Sagittarius A*?

Can withdrawing asylum be illegal?

Can there be female White Walkers?

What is this business jet?

How to notate time signature switching consistently every measure

APIPA and LAN Broadcast Domain

How to type a long/em dash `—`

Deal with toxic manager when you can't quit

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

What do these terms in Caesar's Gallic wars mean?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Are spiders unable to hurt humans, especially very small spiders?

Pokemon Turn Based battle (Python)

Likelihood that a superbug or lethal virus could come from a landfill

A word that means fill it to the required quantity

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Why are there uneven bright areas in this photo of black hole?

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Correct punctuation for showing a character's confusion

Output the Arecibo Message

What is this sharp, curved notch on my knife for?

Are there any other methods to apply to solving simultaneous equations?

Getting crown tickets for Statue of Liberty

What do I do when my TA workload is more than expected?



Chroot doesn't work in PHP5-FPM + nginx



The 2019 Stack Overflow Developer Survey Results Are InBlank Page: wordpress on nginx+php-fpmConfigure php5-fpm for many concurrent usersphpmyadmin having problems on nginx and php-fpm on RHEL 6nginx php5-fpm path_info urls and root locationNGINX don't parse .php5 as .phpLaravel 4.1 on nginx routes error 404nginx PHP files downloading instead of executingCodeIgniter nginx rewrite rules for i8ln URL'sHow to configure nginx to serve one site from two different document root and using different php depending on URLlimit_req_zone for the whole PHP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:



chroot = /home/user/www/public_html
chdir = /


In the server section of my: /etc/nginx/sites-available/default:



root /home/user/www/public_html/site.com;
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /site.com;
fastcgi_param SCRIPT_FILENAME /site.com$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /site.com$fastcgi_script_name;
}


nginx (or fpm I think) tells me: "File not found". Ok I do following:



root /home/user/www/public_html/site.com;
location ~ .php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /home/user/www/public_html/site.com;
fastcgi_param SCRIPT_FILENAME /home/user/www/public_html/site.com$fastcgi_script_name;
fastcgi_param PATH_TRANSLATED /home/user/www/public_html/site.com$fastcgi_script_name;
}


And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:



# ps aux | grep php
root 4696 0.0 1.3 221452 13768 ? Ss 16:52 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)


What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :)
Do I need to do something else to get chroot working?



Also I have:



# cat /var/log/nginx/site.com-errors.com.log
2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"


Ubuntu 14.04:



# php5-fpm -v
PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr 9 2014 17:11:57)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)


Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.










share|improve this question
















bumped to the homepage by Community 14 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.






















    0















    I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:



    chroot = /home/user/www/public_html
    chdir = /


    In the server section of my: /etc/nginx/sites-available/default:



    root /home/user/www/public_html/site.com;
    location ~ .php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param DOCUMENT_ROOT /site.com;
    fastcgi_param SCRIPT_FILENAME /site.com$fastcgi_script_name;
    fastcgi_param PATH_TRANSLATED /site.com$fastcgi_script_name;
    }


    nginx (or fpm I think) tells me: "File not found". Ok I do following:



    root /home/user/www/public_html/site.com;
    location ~ .php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param DOCUMENT_ROOT /home/user/www/public_html/site.com;
    fastcgi_param SCRIPT_FILENAME /home/user/www/public_html/site.com$fastcgi_script_name;
    fastcgi_param PATH_TRANSLATED /home/user/www/public_html/site.com$fastcgi_script_name;
    }


    And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:



    # ps aux | grep php
    root 4696 0.0 1.3 221452 13768 ? Ss 16:52 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)


    What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :)
    Do I need to do something else to get chroot working?



    Also I have:



    # cat /var/log/nginx/site.com-errors.com.log
    2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"


    Ubuntu 14.04:



    # php5-fpm -v
    PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr 9 2014 17:11:57)
    Copyright (c) 1997-2014 The PHP Group
    Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

    # nginx -v
    nginx version: nginx/1.4.6 (Ubuntu)


    Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.










    share|improve this question
















    bumped to the homepage by Community 14 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:



      chroot = /home/user/www/public_html
      chdir = /


      In the server section of my: /etc/nginx/sites-available/default:



      root /home/user/www/public_html/site.com;
      location ~ .php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param DOCUMENT_ROOT /site.com;
      fastcgi_param SCRIPT_FILENAME /site.com$fastcgi_script_name;
      fastcgi_param PATH_TRANSLATED /site.com$fastcgi_script_name;
      }


      nginx (or fpm I think) tells me: "File not found". Ok I do following:



      root /home/user/www/public_html/site.com;
      location ~ .php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param DOCUMENT_ROOT /home/user/www/public_html/site.com;
      fastcgi_param SCRIPT_FILENAME /home/user/www/public_html/site.com$fastcgi_script_name;
      fastcgi_param PATH_TRANSLATED /home/user/www/public_html/site.com$fastcgi_script_name;
      }


      And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:



      # ps aux | grep php
      root 4696 0.0 1.3 221452 13768 ? Ss 16:52 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)


      What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :)
      Do I need to do something else to get chroot working?



      Also I have:



      # cat /var/log/nginx/site.com-errors.com.log
      2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"


      Ubuntu 14.04:



      # php5-fpm -v
      PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr 9 2014 17:11:57)
      Copyright (c) 1997-2014 The PHP Group
      Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
      with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

      # nginx -v
      nginx version: nginx/1.4.6 (Ubuntu)


      Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.










      share|improve this question
















      I have added two line in: "/etc/php5/fpm/php-fpm.conf". There are:



      chroot = /home/user/www/public_html
      chdir = /


      In the server section of my: /etc/nginx/sites-available/default:



      root /home/user/www/public_html/site.com;
      location ~ .php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param DOCUMENT_ROOT /site.com;
      fastcgi_param SCRIPT_FILENAME /site.com$fastcgi_script_name;
      fastcgi_param PATH_TRANSLATED /site.com$fastcgi_script_name;
      }


      nginx (or fpm I think) tells me: "File not found". Ok I do following:



      root /home/user/www/public_html/site.com;
      location ~ .php$ {
      try_files $uri =404;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param DOCUMENT_ROOT /home/user/www/public_html/site.com;
      fastcgi_param SCRIPT_FILENAME /home/user/www/public_html/site.com$fastcgi_script_name;
      fastcgi_param PATH_TRANSLATED /home/user/www/public_html/site.com$fastcgi_script_name;
      }


      And now all works fine. What's wrong with the chroot in fpm? Yeah and by the way - why do it works now when I have set a chroot value! I thought it maybe uses another config but:



      # ps aux | grep php
      root 4696 0.0 1.3 221452 13768 ? Ss 16:52 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf)


      What's my fault? How to find out what's the root of a problem here? It looks like the chroot here doesn't chroot my system :)
      Do I need to do something else to get chroot working?



      Also I have:



      # cat /var/log/nginx/site.com-errors.com.log
      2014/12/02 17:11:20 [error] 5472#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ...., server: site.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "site.com"


      Ubuntu 14.04:



      # php5-fpm -v
      PHP 5.5.9-1ubuntu4 (fpm-fcgi) (built: Apr 9 2014 17:11:57)
      Copyright (c) 1997-2014 The PHP Group
      Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
      with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

      # nginx -v
      nginx version: nginx/1.4.6 (Ubuntu)


      Looks like the chroot doesn't work anymore in php5-fpm. It was working for me for a while before.







      nginx php-fpm chroot






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 2 '14 at 19:07







      JavaRunner

















      asked Dec 2 '14 at 18:03









      JavaRunnerJavaRunner

      913




      913





      bumped to the homepage by Community 14 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 14 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          2 Answers
          2






          active

          oldest

          votes


















          0














          So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.






          share|improve this answer


























          • You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

            – JavaRunner
            Dec 2 '14 at 18:20













          • Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

            – drookie
            Dec 2 '14 at 18:38













          • But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

            – JavaRunner
            Dec 2 '14 at 18:45













          • php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

            – drookie
            Dec 2 '14 at 19:35











          • fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

            – drookie
            Dec 2 '14 at 19:41



















          0














          I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.






          share|improve this answer
























          • I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

            – drookie
            Dec 3 '14 at 5:34











          • But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

            – JavaRunner
            Dec 3 '14 at 12:04











          • Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

            – drookie
            Dec 3 '14 at 12:20











          • But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

            – JavaRunner
            Dec 3 '14 at 16:42











          • You told that it's not correct but how the config should looks like? :)

            – JavaRunner
            Dec 3 '14 at 16:43












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f648619%2fchroot-doesnt-work-in-php5-fpm-nginx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.






          share|improve this answer


























          • You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

            – JavaRunner
            Dec 2 '14 at 18:20













          • Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

            – drookie
            Dec 2 '14 at 18:38













          • But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

            – JavaRunner
            Dec 2 '14 at 18:45













          • php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

            – drookie
            Dec 2 '14 at 19:35











          • fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

            – drookie
            Dec 2 '14 at 19:41
















          0














          So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.






          share|improve this answer


























          • You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

            – JavaRunner
            Dec 2 '14 at 18:20













          • Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

            – drookie
            Dec 2 '14 at 18:38













          • But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

            – JavaRunner
            Dec 2 '14 at 18:45













          • php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

            – drookie
            Dec 2 '14 at 19:35











          • fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

            – drookie
            Dec 2 '14 at 19:41














          0












          0








          0







          So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.






          share|improve this answer















          So you run a pool in chroot, but your paths are pointing to the directory tree without chroot. You should change the paths in the fastcgi_param options to reflect the actual path inside the chroot, so the chrooted php-fpm gets a proper understanding where to look for the php scripts.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 2 '14 at 18:39

























          answered Dec 2 '14 at 18:12









          drookiedrookie

          6,13711219




          6,13711219













          • You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

            – JavaRunner
            Dec 2 '14 at 18:20













          • Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

            – drookie
            Dec 2 '14 at 18:38













          • But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

            – JavaRunner
            Dec 2 '14 at 18:45













          • php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

            – drookie
            Dec 2 '14 at 19:35











          • fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

            – drookie
            Dec 2 '14 at 19:41



















          • You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

            – JavaRunner
            Dec 2 '14 at 18:20













          • Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

            – drookie
            Dec 2 '14 at 18:38













          • But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

            – JavaRunner
            Dec 2 '14 at 18:45













          • php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

            – drookie
            Dec 2 '14 at 19:35











          • fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

            – drookie
            Dec 2 '14 at 19:41

















          You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

          – JavaRunner
          Dec 2 '14 at 18:20







          You mean I need root /site.com;? It doen't work because since that I get an error "404 Not Found" from nginx. Not from php-fpm now. And yeah - html file also don't found. So I think the root path is right because when I place there full path - HTML files load fine. But the php-fpm can't load php scripts. I think it's not nginx's problem it's a php-fpm problem.

          – JavaRunner
          Dec 2 '14 at 18:20















          Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

          – drookie
          Dec 2 '14 at 18:38







          Nah, I mistyped a bit (yeah, you're right). The paths related to the php-fpm. I edited the original answer.

          – drookie
          Dec 2 '14 at 18:38















          But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

          – JavaRunner
          Dec 2 '14 at 18:45







          But what's wrong with my fastcgi_params? :) The full path is: /home/user/www/public_html/site.com and I've set for chroot-variable a value equals to: /home/user/www/public_html so I use for fastcgi_param a prefix: /site.com

          – JavaRunner
          Dec 2 '14 at 18:45















          php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

          – drookie
          Dec 2 '14 at 19:35





          php-fpm runs chrooted in /home/user/www/public_html. Your nginx tells the php-fpm to look for the scripts in /home/user/www/public_html/site.com (according to yours nginx.conf), but nginx itself isn't chrooted. So php-fpm tries to look for the scripts in /home/user/www/public_html/site.com, and this is relative to it's /, which is /home/user/www/public_html/site.com itself. So php-fpm actually looks for the scripts in /home/user/www/public_html/site.com/home/user/www/public_html/site.com which doesn't exist. That's the reason for the Primary script unknown.

          – drookie
          Dec 2 '14 at 19:35













          fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

          – drookie
          Dec 2 '14 at 19:41





          fastcgi_param is an array of variables which is passed to the php-fpm directly, without translation. that's why you have to translate them yourself between chrooted and non-chrooted environments.

          – drookie
          Dec 2 '14 at 19:41













          0














          I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.






          share|improve this answer
























          • I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

            – drookie
            Dec 3 '14 at 5:34











          • But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

            – JavaRunner
            Dec 3 '14 at 12:04











          • Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

            – drookie
            Dec 3 '14 at 12:20











          • But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

            – JavaRunner
            Dec 3 '14 at 16:42











          • You told that it's not correct but how the config should looks like? :)

            – JavaRunner
            Dec 3 '14 at 16:43
















          0














          I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.






          share|improve this answer
























          • I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

            – drookie
            Dec 3 '14 at 5:34











          • But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

            – JavaRunner
            Dec 3 '14 at 12:04











          • Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

            – drookie
            Dec 3 '14 at 12:20











          • But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

            – JavaRunner
            Dec 3 '14 at 16:42











          • You told that it's not correct but how the config should looks like? :)

            – JavaRunner
            Dec 3 '14 at 16:43














          0












          0








          0







          I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.






          share|improve this answer













          I've solved the problem. I didn't make any changes to my configs. I've just done "aptitute update && aptitude upgrade" and voila - now it works with my configs listed above. So I think that was a bug.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 2 '14 at 20:21









          JavaRunnerJavaRunner

          913




          913













          • I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

            – drookie
            Dec 3 '14 at 5:34











          • But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

            – JavaRunner
            Dec 3 '14 at 12:04











          • Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

            – drookie
            Dec 3 '14 at 12:20











          • But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

            – JavaRunner
            Dec 3 '14 at 16:42











          • You told that it's not correct but how the config should looks like? :)

            – JavaRunner
            Dec 3 '14 at 16:43



















          • I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

            – drookie
            Dec 3 '14 at 5:34











          • But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

            – JavaRunner
            Dec 3 '14 at 12:04











          • Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

            – drookie
            Dec 3 '14 at 12:20











          • But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

            – JavaRunner
            Dec 3 '14 at 16:42











          • You told that it's not correct but how the config should looks like? :)

            – JavaRunner
            Dec 3 '14 at 16:43

















          I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

          – drookie
          Dec 3 '14 at 5:34





          I seriously doubt you solved anything. I bet now your php-fpm just stopped being chrooted.

          – drookie
          Dec 3 '14 at 5:34













          But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

          – JavaRunner
          Dec 3 '14 at 12:04





          But how can I check it? I see the value of $_SERVER["SCRIPT_FILENAME"] variable from php-script and it tells me: "/site.com/test.php". I think it's chrooted now, right?

          – JavaRunner
          Dec 3 '14 at 12:04













          Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

          – drookie
          Dec 3 '14 at 12:20





          Seems like it. However, the fastcgi variables array with values like /home/user/www/public_html/site.com* is still incorrect for chrooted php-fpm. Only if aptitude has somehow automagically cured your config, but this seems unlikely.

          – drookie
          Dec 3 '14 at 12:20













          But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

          – JavaRunner
          Dec 3 '14 at 16:42





          But how can I get values of those variables? I tried to find any occurrence something like "www" in the output of "phpinfo()" and there's no any occurence in it! I tried to find "www" because it contains in the full path: "/home/user/www/public_html". Maybe I check it wrong?

          – JavaRunner
          Dec 3 '14 at 16:42













          You told that it's not correct but how the config should looks like? :)

          – JavaRunner
          Dec 3 '14 at 16:43





          You told that it's not correct but how the config should looks like? :)

          – JavaRunner
          Dec 3 '14 at 16:43


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f648619%2fchroot-doesnt-work-in-php5-fpm-nginx%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Маріан Котлеба Зміст Життєпис | Політичні погляди |...