How to get PHP mysql_ extension for linux chroot jail?
I've setup a chroot jail using jailkit on my Ubuntu 10.04 system. I've copied the binaries for php and mysql which all worked fine. So from the command line of my chrooted user I can run php somefile.php
commands which work great.
However the problem is that none of my php extensions are available from the chroot. The main one I need is the mysql extension. This works fine from my root account, but not when I'm logged into the chrooted user.
I've run the command php --ini
on both accounts with the following results:
From the root account it looks like:
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: /etc/php5/cli/php.ini
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/geoip.ini,
/etc/php5/cli/conf.d/imagick.ini,
/etc/php5/cli/conf.d/mcrypt.ini,
/etc/php5/cli/conf.d/memcache.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini,
/etc/php5/cli/conf.d/ssh2.ini,
/etc/php5/cli/conf.d/suhosin.ini,
/etc/php5/cli/conf.d/tidy.ini
And from the jail it looks like:
Configuration File (php.ini) Path: /etc/php5/cli
Loaded Configuration File: (none)
Scan for additional .ini files in: /etc/php5/cli/conf.d
Additional .ini files parsed: (none)
The path /etc/php5/cli
doesn't exist in the chroot, so I'm assuming that this refers to the actual root path, which of course does exist.
So the problem appears to be that none of the php extensions load in the chroot. But I've got no idea why this would be?
Normally you do not copy the libraries and such to the jail. What you do is to run different jailkit commands. These commands creates links rather than copying the files.
If you have created a jail before you added php, you can follow the process explained here:
https://www.faqforge.com/linux/add-php-in-ssh-jail-ispconfig-3/
What I ended up doing (because jailkit returned with an error when doing jk_update) was this:
jk_init -j /var/www/clients/client123/web123/ basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh php
Here is the link to the jailkit site where you can see more commands
https://olivier.sessink.nl/jailkit/