tags:

views:

899

answers:

4

I need to enable the mcrypt functions on my website, except I'm on a shared host (running linux) and obviously don't have access to the php.ini file. There does seem to be options for installing PEAR modules but a search told me mcrypt wasn't available. Is there any way I can do this, short of begging technical support to help me?


Update: Looking around a bit more, it looks like I might be able to use the dl() function to dynamically load a library at run time. Since I'm only using the mcrypt functions in one spot, I could probably get away with doing this since the performance hit (I assume there is a hit) should be minimal. The only problem now is how to get the libmcrypt.so file?


Another update: I've downloaded the libmcrypt.tar.bz2 file from Sourceforge and run ./configure, make, and then copied the libmcrypt.so.4.4.8 file into my home directory (as libmcrypt.so), but now I can't find where to put it so that the dl() function will find it.

+2  A: 

The MCrypt Sourceforge page should have it http://mcrypt.sourceforge.net/
To compile it just:

wget http://superb-east.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz
tar -xzvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
sudo make install

EDIT: Can you reference it with a direct path?
What have you tried?

Edit2: It seems that you can only load moduals from the extensions directory set in the php.ini and you cannot override extensions_dir with ini_set so you will either have to convince your host to install it or if they allow you to have your own php.ini (many do usually in [username]/php.ini) then you could set the extensions_dir in there and load the modual with that.

Unkwntech
ah well that sudo part isn't going to work, since I'm on a shared host.
nickf
well you would have to build it first, I'll build one now and post a link.
Unkwntech
thanks for the offer(!), but i've been able to build it (see my latest edit)
nickf
OK, no problem...
Unkwntech
dl doesn't accept any path information - only the file name.
nickf
Yah I just found that...
Unkwntech
thanks for all your effort, unkwn!
nickf
I have had this problem myself before, but I worked around it at the time then moved to a dedicated server, I was hoping that there was a solution now, but I can understand the reasons that there isn't.
Unkwntech
+1  A: 

Really the best way is to tell your ISP to include mcrypt support. Even if you bundle your own PHP extension and load it with dl(), there is no guarantee it is going to work after a PHP upgrade, as PHP is sometimes very version-number picky.

Vincent
A: 

dl() will not help you either, since it only loads libraries from certain paths, and those paths are usually only writable by the system administrators for security reasons.

I very much doubt that there is a way to use binary libraries without the consent of the hoster.

hop
A: 

PHP in versions before 5.2.5 allowed you to use a path in the dl() function so that you could easily load libraries in a shared environment.

This changed for 'security' reasons with 5.2.5 and as far as I am aware your only option is to get your system administrator to add the module to the extensions_dir.

This issue is described at bugs.PHP.net