Search code examples
apachephpubuntu-14.04chroot

apache php5-fpm 404 error on chroot enable


I know this particular question has been asked many times but i don't see any solving answers.

I have a mod_proxy_fcgi + php5-fpm + apache 2.4 configured on UBUNTU 14 its working perfectly fine.

i wanted to make php-fpm chrooted (So users wont access other users resource in shared env) if config:

prefix = /var/www/html/example.com/public_html/ 
chroot = $prefix 
chdir = / 

After config: if i access php script in browser i get 404 error "File not found"

If i COMMENT this above chroot config then php works again without any errors!


Solution

  • At Freenod Channel #php-fpm person named "Kiranos" helped me to solve the problem.

    My setup was: Apache 2.4.7 + mod_proxy_fcgi + php5-fpm on Ubuntu 14.04

    The problem was, i had TCP connection to php-fpm socket in vhost like

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/example.net/public_html/$1
    

    and in php-fpm pool conf i had

    chroot = /var/www/html/example.net/public_html/
    

    Note: Since Apache 2.4.7 don't support unix socket connection i had to use TCP. While using TCP there is no need to mention complete doc path in ProxyPassMatch for chrooting.

    Wrong Conf in vHost:

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/example.net/public_html/$1
    

    Correct Conf in vHost:

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/$1
    

    After doing this chroot was working..