I am on shared hosting, and I noticed the PHP does not include bzip2. It seems I would have to re-compile PHP inorder to use this. I don't think shared hosting allows this, so is there any alternative to my situation or bzip2?
Asked
Active
Viewed 136 times
0
-
You moderators are on top of things. 2 Mod edits. <3 SO. – Strawberry Oct 17 '10 at 07:07
-
You should really just try asking your webhosts before you get to hung up with high tech stuff. If they say yes, then great, if they say no then you probably want to look elsewhere anyway cause if you do a high-tech work around and they find out, they may be pissed. And even if it works, what guarantee do you have it'll work in the future? Lekensteyn's answer requires PHP < 5.3 - one upgrade and your site stops working. With shared hosting you really are in their hands, and if that doesn't work for you then tough. – James Oct 17 '10 at 07:26
-
If you only need to compress/uncompress documents, and it's not mandatory that it be the bzip2 format, there are zip classes written in pure PHP that you can use. – mellowsoon Oct 17 '10 at 07:28
-
@James Taken. Appreciate the advice. @mellowsoon Well, the script depends on bzip2. I thought finding a way to use bzip2 might be better than re-writing it. – Strawberry Oct 17 '10 at 07:30
1 Answers
1
If your host allows dl()
(I doubt it), you can dynamically load a shared extension.
Checklist for dl
:
dl
should not be listed indisable_functions
safe_mode
off- PHP < 5.3
enable_dl
On- Operating system (Win32 requires DLLs, Linux requires .so files)
- The extension should be available in the extension directory of PHP.
The best thing you can do is asking your host to enable bzip2 support, and otherwise search for an alternative. There are plenty hosts with bzip2 supported.

Lekensteyn
- 64,486
- 22
- 159
- 192
-
I AM IN LUCK! It is enabled. How do I get the extension though? Do I have to download it from somewhere? – Strawberry Oct 17 '10 at 07:09
-
What OS is your server running on? Win32 or Linux? Is the server running as module (Apache) or CGI? You can check that using `phpinfo()`, look for `System` and `Server API`. – Lekensteyn Oct 17 '10 at 07:14
-
-
-
Just paste the full System line from phpinfo(). It should be noted there – Lekensteyn Oct 17 '10 at 07:20
-
-
Debian 64 bits download: http://packages.debian.org/lenny/ia64/libbz2-1.0/download. Unpack it on your computer and upload `lib/libbz2.so.1` to `libbz2.so` on your server. – Lekensteyn Oct 17 '10 at 07:30
-
Unpacked, where do I upload it to? Is this right? `dl("libbz2.so.1"); dl("libbz2.so.0"); dl("libbz2.so.0.4");` – Strawberry Oct 17 '10 at 07:57
-
Oops, I missed this line: `This parameter is only the filename of the extension [...] The directory where the extension is loaded from depends on your platform`. Sorry for the confusion, but you really have to contact your hosting provider. – Lekensteyn Oct 17 '10 at 08:33