I'm running Ubuntu, with PHP5-FPM, mysql & Nginx

I've just setup a chrooted jail with jailkit. Now I need to work out how to setup my php and mysql to work within the jail.

Google search doesn't give me much, and there's no documentation for this on the jailkit website. (It may be easy but I'm fairly new to this field)


Here is a sample configuration section that you can put in /etc/jailkit/jk_init.ini so that future jail adds are seamless.

I used this section

comment = mysql client
executables = /usr/bin/mysql
paths = /usr/lib/libmysqlclient.so.16.0.0 , /usr/lib/libmysqlclient.so.16, /usr/lib/libstdc++.so.6,/usr/lib/libstdc++.so.6.0.13,/lib/libgcc_s.so.1

Seemed to work well, you may need to change some paths. jailkit MAY resolve the symlink paths on its own but i added both in case.

Two caveats

1) Users must use full mysql -h syntax (mysql -h basehostname database) since you do not have the mysql local sockets in the jail

2) Your mysql must be listening on the public interface so the jail can connect to it.


Figured it out anyhow!

Just find out where the php & mysql binaries reside (/user/bin or /user/sbin) and copy them to the relative chroot directory. Then when you run the php command from the chroot user you'll get an error saying such and such a libary is missing so then you've just got to find that libaray and copy it into the relative chroot directory and keep going like that until all the dependant libraries have been copied over.

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.