Where are PHP extensions when installing from source? - php

When I try to run a PHP scripts I get the following errors:
Warning: PHP Startup: Unable to load dynamic library '/home/user/php-5.4.28/installdir/include/php/ext/php_bz2.so' - /home/user/php-5.4.28/installdir/include/php/ext/php_bz2.so: cannot open shared object file: No such file or directory in Unknown on line 0
php.ini:
extension_dir = "/home/user/php-5.4.28/installdir/include/php/ext"
Content at extension_dir path:
~/php-5.4.28/installdir/include/php/ext$ ls
date ereg gd iconv libxml mysqli pcre session sqlite3 xml
dom filter hash json mbstring mysqlnd pdo spl standard
Where do I locate the extension?
I have installed PHP from source.
All the errors and phpinfo() can be seen here on JSBin

You don't have to locate the extension. You have to recompile PHP passing the option --with-bz2 to the ./configure script. Bzip2 support is not enabled by default as official documentation says.
./configure --with-bz2
Keep in mind that in order to compile PHP with this extension you need development headers and/or libraries. If they are missing ./configure will fail saying what's missing. If this will happen simply use your package manager (apt, yum or zypper - distro dependent) to install required packages and retry.
It's also likely that your PHP apps are using other extensions. The procedure is exactly the same. You just add more options. Let's say that curl is also needed, then:
./configure --with-bz2 --with-curl
will work - again more headers and packages needed.
Remember to always use all the options you need as the results of former compilations are overwritten.

Related

Local host yii gives this type of error : yii\base\ErrorHandler::handleFatalError()

PHP Core Warning – yii\base\ErrorException
PHP Startup: zip: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match
2. yii\base\ErrorHandler::handleFatalError()
Webpage runs ok but at the end of page this errors come. i tried one method which remove these errors temporary which are written in terminal.
# pecl upgrade fileinfo # pecl upgrade memcache # pecl upgrade mhash # pecl upgrade readline
thanks in advance.
I think they are not compatible, It might be versions issue so please perform the following steps:
Update your PHP.
Update your modules (PHP extensions).
Here is how you can update your PHP extensions. You must either
Check what your distribution provides
Or use the pecl command, to
re-download the sources of the extensions in question, and re-compile
them.
First install it
pecl uninstall module_name
Then install it
pecl install module_name
Don't forget to restart the Apache.

How to compile php extension for PHP 5.3.6 with debug, TS

I've tried to create some php extension.
For the first I compiled php 5.3.6 with --enable-debug --enable-maintainer-zts.
Then I ceated my extension and use standart procedure for it
phpize
./configure --with-EXTNAME
make
Then copy extname.so to my php extensions directory, and change php.ini
And when I try to use php from cli I got an error
Unable to initialize module
Module compiled with build ID=API20090626,NTS
PHP compiled with build ID=API20090626,TS,debug
When I try
./configure --enable-debug --enable-maintainer-zts
For extension I got warning that these options are not recognized by configure script.
So, how can I compile my extension to use with PHP compiled with options that I describer above without recompiling php itself?
You need ./configure --with-php-config=/path/to/correct/php-config.
The configure script is likely using another php-config (likely the centrally installed one).
in my server there are 2 phpize
/usr/bin/php/phpize
/usr/bin/php-zts/phpize
to make sure it compiled with Thread Safety instead using "phpize" do
/usr/bin/php-zts/phpize
./configure --with-php-config=/usr/bin/php-zts/php-config
make
make install

Needing an explanation regarding PHP extentions

Here is a quick overview:
I just finished compiling PHP 5.3.5 and made the attempt to compile "--with" a number of different extensions. Among the extensions that I need are mbstring and intl. I can manually phpize, configure, make, make install the mbstring extension and it seems to work fine. However, I am unable to do the same for intl.
My ./configure line looks like this:
./configure --with-openssl --with-pcre-regex --enable-calendar
--with-curl --enable-exif --enable-ftp --with-gd
--with-mhash --enable-mbstring --with-mysql --enable-zip
--enable-intl --with-icu-dir=...
The code compiles without problem: ./configure... make, make install
I used the php.ini-production for my php.ini configuration and I configured Apache to use php-cgi for a specific domain, and that works fine as well.
A quick:
<?php phpinfo() ?>
reveals that I am in fact running the newer version of PHP. However, the extensions specified in the "./configure..." line do not show up anywhere on the PHP info page.
After a bit of scouting I found that I could run phpize on a single extension in the PHP source folder, then compile a build of the specific module and install it in my PHP extension directory. After adding:
extension=MY_EXT
in my php.ini, the extension showed up on my phpinfo() page.
So can anyone explain why --with-mbstring doesn't seem to have an effect on my compilation?
I had no compilation problems for the intl extension, but moving the intl.so file to my PHP extensions directory and adding an extension line in my php.ini has no effect.
From php.net, have you tried
If your ICU is installed to a
non-standard directory then you might
want to specify its location in
LD_LIBRARY_PATH environment variable
so that dynamic linker can find it: $
export LD_LIBRARY_PATH=/opt/icu/lib
Otherwise, if PHP and ICU are
installed to their default locations,
then the additional options to
`configure' are not needed.

PHP ICONV glibc to libiconv on CentOS 5.5

I'm having a few issues with the PHP function iconv, which I've tracked down the the iconv implementation. As the manual states, "Note that the iconv function on some systems may not work as you expect. In such case, it'd be a good idea to install the GNU libiconv library." http://uk3.php.net/manual/en/intro.iconv.php
I've downloaded the libiconv library from http://www.gnu.org/software/libiconv/ and installed it without any problems using:
$ ./configure --prefix=/usr/local
$ make
$ make install
My problem now is how to link this installation to PHP? From what i've read I need to recompile PHP with --with-iconv-dir=/usr/local/
but how do I do this on CentOS? I installed php with yum install php.x86_64
I tried yum reinstall php but when I service httpd restart my phpinfo reads the same, glibc.
Is there a better way to install libiconv on CentOS? If not how do I get PHP using this installation without upsetting yum?
Many thanks in advance
compiled php from source seems to be the way
php -m > /tmp/php.modules to list of compiled module for php
backup your current php.ini
yum uninstall php
download the php
and base on your existing module + iconv - almost all steps has been detailed here : http://www.php.net/manual/en/install.unix.apache2.php#90478 (except never advise u to backup php.ini)
You should manually recompile the php iconv extension (in the php-x.y.z/ext/iconv/ subdirectory) after manual changing of the configure script to force it to select GNU libiconv instead of glibc's iconv. See my answer for the similar Stack question.

Enabling ZLib support in PHP

I'm installing a PHP script in my server and when I try to run the test page, I get an error saying:
PHP needs to be compiled with ZLib support enabled (--with-zlib[=DIR])
How can I fix this on Apache?
I assume this is on linux?
As the error says, you need to recompile your PHP installation.
Take a look at the Makefile in the folder where you have the PHP source to see the ./configure line that was used last time, use all of the same options with the addition of --with-zlib
./configure --with-zlib ...(other config options)...
make
make install

Categories