# Php-fpm and chroot on linux

**URL:** <https://www.ruby-forum.com/t/php-fpm-and-chroot-on-linux/192422>\
**Category:** NGINX\
**Created:** [July 29, 2010, 11:11pm UTC](https://www.ruby-forum.com/t/php-fpm-and-chroot-on-linux/192422 "2010-07-29T23:11:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [July 29, 2010, 11:11pm UTC](https://www.ruby-forum.com/t/php-fpm-and-chroot-on-linux/192422/1 "2010-07-29T23:11:50Z")

</div>

Hi nginx-en ml.

This is not exactly nginx issue, but lets say this is nginx related  
thing.

php-fpm and chroot - It is working for me good, I haven’t tested  
performance yet but there is two things what I need fix before I can  
really use it.

First issue: php in chroot can’t resolve names. Even puting  
/etc/resolv.conf in chroot isn’t solution.

2nd issue: mysqld socket. If I want connect to ‘localhost’ it using  
unix:///var/run/mysqld.socket which is really smart and I like it (I  
want use socket if I can.). it not work, because in chrooted env there  
is no mysqld socket. There is any better way than mount -o bind ‘run’  
dir into each chroot’s root?

Sorry for posting it on nginx list but this is best place to ask in my  
opinion.

– Piotr.

---

<div class="post-metadata">

**Author:** ![hibernaculus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/6de8d8/32.png) [@hibernaculus](https://www.ruby-forum.com/u/hibernaculus)\
**Post date:** [July 29, 2010, 11:41pm UTC](https://www.ruby-forum.com/t/php-fpm-and-chroot-on-linux/192422/2 "2010-07-29T23:41:06Z")

</div>

2010/7/29 Piotr K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi nginx-en ml.
> 
> This is not exactly nginx issue, but lets say this is nginx related thing.
> 
> php-fpm and chroot - It is working for me good, I haven’t tested performance  
> yet but there is two things what I need fix before I can really use it.

There should not be a revelant gap of perf between using and not using  
chroot.

> First issue: php in chroot can’t resolve names. Even puting /etc/resolv.conf  
> in chroot isn’t solution.

try putting also /etc/hosts and /etc/nsswitch.conf into the chroot. Is  
it better ?

> 2nd issue: mysqld socket. If I want connect to ‘localhost’ it using  
> unix:///var/run/mysqld.socket which is really smart and I like it (I want  
> use socket if I can.). it not work, because in chrooted env there is no  
> mysqld socket. There is any better way than mount -o bind ‘run’ dir into  
> each chroot’s root?

if you have only one chrooted env, you can setup mysqld to write its  
unix socket into the chroot (ex:  
/path/to/chroot/var/run/mysql.socket). Then the socket will be  
available from inside and from outside the chroot.

If you have more than one chrooted env, then you can’t use unix  
socket. You’ll have to use TCP on localhost.

> Sorry for posting it on nginx list but this is best place to ask in my  
> opinion.

you should continue this conversation on  
[http://groups.google.com/group/highload-php-en](http://groups.google.com/group/highload-php-en).
