Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Enabling mbstring extension

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
canary
Posts: 12
Joined: 2007-04-03 14:38

Enabling mbstring extension

#1 Post by canary »

Hello,

I just installed Php5, but I need mbstring extension. How do I enable this extension?

Thanks.

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

#2 Post by bugsbunny »

It looks like you'll have to recompile php5 yourself in order to enable that extension.

Probably the easiest way to do that (this is untested by me in terms of php5):

install the apt-src, build-essential packages, and fakeroot packages
create a directory ~/source
start a terminal
cd to ~/source
apt-src php5

(This will download and expand the source for php5 (assuming you have the appropriate deb-src lines in your sources.list file). It will also check for and download/install the build dependencies for the package (although enabling additional options, as you're doing here, may add additional dependencies - which won't appear until you go to compile. At which point you'll have to install the new dependencies and recompile. But this will get the bulk of them).

in the new directory that was just created find the debian/rules file
Edit that file and find the section with the php5 config options. (A bunch of --enable-xxx and --with-xxx statements). Add --enable-mbstring to the list.

Next change the debian/changelog file. Note that the format inside this file is important, else it will throw an error when you try to compile. Easiet way to do this is to just copy/paste the first section starting with the first libe of the file and ending with the blank line following the first line that starts with:
-- <maintainers name> <mainainers email> <date/time field>. So duplicate this section at the top of the file.
Edit the first line and add a suffix to the version (inside the parentheses) Simply add a string "+your initials" (without the quotes and replacing the phrase your initials with your actual initials :) )

Modify the comments section - you can just delete most of them and say "recompile to enable mbstring".

Change the maintainer line to reflect your name, email address, and the current date/time. Make sure you maintain the same format and spacing on this line as what exists.

Save the file.

Go back to the root of the source and issue the following command:
dpkg-buildpackage -b -rfakeroot -us -uc

That will perform the entire compile pricess for you. If it throws any errors correct them (probably additional dependencies, or you messed with format of the control file) and rerun the command. Once it completes successdully you should have a bunch of deb files in the ~/source directory. To install I recommend that you use gdebi (you'll probably have to install gdebi first)

simply run (from inside ~/source):
# gdebi php5_<version>.deb

(gdebi has the advantage over dpkg -i in that it will resolve and install any needed dependencies).

Actually the compile may generate a package called php5-mbstring_<version>.deb
If that's the case then all you need to do is install that package. (although you may have to force it because of the new version number you generated. In which case the command to install it would be:

Code: Select all

# dpkg -i --force-depends-version php5-mbstring_<version>.deb
or you could recompile using the original changelog)


Hope this helps - it's not as hard as it sounds (at least if everything works the way it should).

canary
Posts: 12
Joined: 2007-04-03 14:38

#3 Post by canary »

Thank you very much, bugsbunny. It's really very complicated. Propably it's easier to reinstall php?

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

#4 Post by bugsbunny »

Re-installing php won't help without the recompile. As a default mbstrings isn't enabled in php. You have to recompile php in order to enable mbstrings.

PHP: Installation - Manual
mbstring is a non-default extension. This means it is not enabled by default. You must explicitly enable the module with the configure option.
It's really not that complicated :) It just sounds scary. If you need mbstrings you're going to have to recompile.

You could write to the maintainers and ask them to create a php5-mbstrings package - but even if they do that it will probably take a while.

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

#5 Post by bugsbunny »

Ok, I actually found a version that has mbstring enabled. From here:
http://de.php.net/manual/en/install.unix.debian.php

Add the following to your sources.list

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

The packages are compiled against etch. To install
aptitude update
aptitude install php5=5.2.8-0

I've never used the above repository, so use at your own risk.

canary
Posts: 12
Joined: 2007-04-03 14:38

#6 Post by canary »

Thank you bugsbunny.
I have Debian Lenny. I hope it will work.

Post Reply