Installing pecl/imagick giving me module api compile errors - php

I've installed php 5.4.0, and went to re-install Imagick, from Pecl. When doing so everything works well, but when apache starts the following error is logged and the extension is not loaded as it should be:
PHP Warning: PHP Startup: imagick: Unable to initialize module\
Module compiled with module API=20090626
PHP compiled with module API=20100525
These options need to match in Unknown on line 0
For the life of me I can't understand where "20090626" is coming from. phpize -v shows:
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
And the same is printed when the pecl installation process starts. How do I correct this?

I had exactly the same problem as you when I compiled php from source. And had a previous php5-pear, php5-cli installed. I don't know why but I had to remove every single file still marked as "php5".
To find the files (should work on OSX too):
find / -name php5
Then just do rm -r /paths/that/are/listed/php5
When thats finished, just go into your bin folder of your new php installation and reinstall the mongo-driver with pecl. I had to do: sudo ./pecl uninstall mongo followed by sudo ./pecl install mongo
When the installation is finished, if you're using php-fpm dont forget do use sudo service php-fpm restart
Then it should work, check by typing (all this still in the php/bin folder):
sudo ./php -v
If you dont recieve any errors you should be good to go :)
//cubsink

Related

Mac OS: Intl extension is not loaded

macOS Mojave 10.14.3
PHP 7.1.23
Prestashop 1.7.5.1
I tried to install PHP intl extension on my local server in order to use Prestashop.
I added extension=php_intl.so to etc/php.ini
When I try to install Prestashop I get Intl extension is not loaded.
$ php -m | grep intl
When I do $ php -m | grep intl, I get:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/pecl/20160303/php_intl.so' - d
lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen
(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
intl
It seems that the file php_intl.so doesn't exist.
$ sudo pecl install intl
I also tried $ sudo pecl install intland I get:
make: *** [php_intl.lo] Error 1
ERROR:make' failed`
$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
I also tried $ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 and it doesn't create the intl.so file.
How can I solve this problem?
Brew's PHP 7.1, 7.2 and 7.3 all have INTL enabled by default.
Most probably, you're just using your Mac OS' bundles version of PHP.
Run
ls -l $(which php)
to find out where the current PHP binary is located and whether it is symlinked to a Brew installation or not. In my case, for example:
lrwxr-xr-x 1 27 May 23 16:30 /usr/local/bin/php -> ../Cellar/php/7.3.5/bin/php
Meaning that my php is linked to Brew's 7.3.5 version.
If you are NOT using Brew's PHP, you'll see something like
-rwxr-xr-x 1 11169664 Mar 21 07:09 /usr/bin/php
Installing PHP through Brew
Find out whether you've already installed PHP:
brew list | grep php
If there is any output, and your version of PHP is present, go to step 2, or use step 1 to update PHP to the latest version.
1. Install Homebrew's PHP
brew install php#7.3
(or 7.2, 7.1). If Brew complains about not being able to find a formula, you might have messed with taps. Instead of php#7.3, you could try to supply the full path to the current php formula:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb
Still not working, check whether you are running a recent version of Homebrew brew --version.
Homebrew 2.1.3-31-geaf2370
Homebrew/homebrew-core (git revision fd1ef; last commit 2019-05-25)
Homebrew/homebrew-cask (git revision 16d50; last commit 2019-05-26)
2. Link Homebrew's PHP
Now, to have php 'in your path', there are two options.
a) Either homebrew's version must be linked from its install location (/usr/local/bin/Cellar/php....) to a directory in your path (e.g., /usr/local/bin). To do this, run:
brew link --force php#7.3
If you are not able to link, this is typically caused by set permissions or System Integrity Protection. In the first case, try sudo chown "$USER":admin /usr/local/bin/php.
b) Or, add the /usr/local/opt/php#7.3 directory (opt-prefix) to your $PATH variable. E.g., for Bash:
echo 'export PATH="/usr/local/opt/php#7.3/bin:/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
3. Validate installation
ls -l $(which php)
should show that php is linked to a Homebrew PHP installation in /usr/local/bin/Cellar.
php -v
should show the recently installed version of PHP. Try to restart your terminal if that's not the case.
php -i | grep -i intl
should show some information about the current install of intl.
If you're using webservers and/or PHP FPM, this is the time to restart those services. (Or restart your system, if you don't know how to do that and cannot figure out).
Possible issues
If you still get warnings about missing extensions (Unable to load dynamic library, etc.), then your php.ini is messed up.
Find the current location of php's ini
$ php -i | grep \.ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
....
Edit /usr/local/etc/php/7.3/php.ini and find the offending extension load (e.g., extension="myext.so"). Comment out those that cannot be found.
Homebrew permissions
Some argue that it's a good idea to chown /usr/local.
sudo chown -R "$USER":admin /usr/local
This will make installing things here, by hand and through Homebrew, a lot easier, but also a bit less secure too, since non-root processes are now allowed to write here too.
Your web-application is using a different version of PHP.
Make sure that it doesn't... The configuration of this depends on the used webserver. A first step would be to output the current PHP configuration in your web-application with <?php phpinfo();.
This explains steps for Apache.
Another way to get a webserver + PHP stack running quicly is using Laravel Valet.
Installing additional extensions
To install additional PHP extensions, use PEAR.
pear -V
should output the current PEAR and PHP version.
PEAR Version: 1.10.9
PHP Version: 7.3.5
Zend Engine Version: 3.3.5
Now, to install an extension, for example, PHP's yaml extension:
pear install yaml
I have seen a lot of answers about this problem and anyone helped me, but the last (of course). This is for XAMPP´s use.
Xcode is needed.
Download the version of php you use in xampp from php.net.
Extract it and open the extracted folder in a terminal using cd.
Change to subfolder ext/intl.
Run these commands to build the extension:
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install (password required)
Delete all files you downloaded and also the extracted folders.
Add to php.ini file in xampp/etc folder line
extension="intl.so"
Original link: https://community.apachefriends.org/viewtopic.php?p=255061&sid=27afc55649dfe6ea7b0824cb0bb8486b
Since php 7 it's not necessary load the extension php_intl.so, what do you need to do?, edit your php.ini and delete or comment the line that is loading the extension php_intl.so, after this reload your apache and try again.
There might be an issue with brew
You could try to use this as mentioned there:
brew tap kyslik/homebrew-php
brew install kyslik/php/php71-intl
i tried all but intl not working in mac so please uninstall xampp and install mamp it will work
So, on Pecl Official site ( https://pecl.php.net/package/intl ), it's clear that Intl package is not maintained anymore and has been superseded. Since PHP 5.3.0 you don't need to use Pecl to install intl extension, it's bundled with PHP.
But, it's missing on native instalation of PHP 7.1.24 on Mac OS Mojave.
if you wanna use only native apache and php pre-installed instead of using homebrew, do this:
Download PHP 7.1 from php.net, install XCode Command Line Tools, ICU (http://site.icu-project.org/), Autoconf, reinstall the developer tools header files, and finally install Intl extension using phpize.
Important: you'll have to disable SIP.

Install PHP modules on CentOS

I'm trying to install PHP 5.5.21 on CentOS 7.0.
When I execute php -v
I get about 10 modules errors like this one:
PHP Warning: PHP Startup: curl: Unable to initialize module
Module compiled with module API=20100525
PHP compiled with module API=20121212
I tryed to install or update package with pecl install curl and pecl upgrade curl
But pecl always responds :
No releases available for package "pecl.php.net/curl"
And yum install php-curl says:
Package php-common-5.4.16-23.el7_0.3.x86_64 already installed and latest version
Nothing to do
How can I do to fix modules error?
Try running: find / -name curl.so
Then copy the directory it finds curl.so in and create a symbolic link to it where the rest of your working .so files are stored:
cd <where your working .so files are>
ln -s <where curl.so is> curl.so
Then edit your php.ini file and enable the extension:
extension=curl.so
Restart apache:
service httpd restart
service apache2 restart `#If the service is named apache2 rather than httpd`
This resolved my problem when I had a similar issue.
I finally solved my problem removing the custom PHP installation and using this tutorial to install PHP 5.5

How to build mongo.so or PHP with the correct module api version

Trying to install mongoDB on my MAMP setup. I have MAMP 3.05, which comes with PHP 5.5.10. Installed mongo using the instructions from the mongo website and it seems to be running properly. Grabbed mongo extension from the mongo github page and followed their instructions for building and adding the extension to php.ini.
Everything seems ok until I restart MAMP. In php_error.log, I see this:
PHP Warning: PHP Startup: mongo: Unable to initialize module
Module compiled with module API=20100525
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
It looks like the API number for php is a later version, so it would be nice not to have to rebuild an older version of PHP. Is there a way to rebuild the mongo extension with the correct module version, or do I have to discard MAMP and build PHP manually?
Please check with the command which phpize if you use the correct version of the phpize command. This should point to a directory similar to the one you installed your PHP5 into. Mine is found in /usr/bin/phpize which is the default OS X installation.
You can further run phpize -v to check the API version it links against. In my case (the default OS X PHP installation) it outputs:
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
If the outputted API version does not match your required number 20121212 (in my case it is 20100412 which does not match) you are using the wrong phpize to configure the extension.
You have to do this first
sudo cp -r /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/S‌​DKs/MacOSX10.10.sdk/usr/include/php /usr/include/php

PHP redis error

I installed the php redis extension. But when I run the test code, I got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/redio.so' - /usr/lib/php5/20090626+lfs/redio.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error: Class 'Redis' not found in /var/www/test/redisTest.php on line 2
My php version is 5.3.10, I installed the new version of phpredis.
May I get your help?
THANKS!
The install steps are:
git clone https://github.com/nicolasff/phpredis.git
cd phpredis
phpize
make
make install
Then add a config file in /etc/php5/fpm/confi.d to load redis.so
I use PHP 5.3 and installing PHP-Redis using below steps worked just fine for me:
Install pecl extensionsudo pecl install redis
In php.ini, you may need set extension_dir to correct value. (can be usr/lib64/php/modules as above command placed the redis.so in this directory). In my case, I didn't set this.
Add below line to php.ini:extension=redis.so
Restart Apache/PHP-FPM
To verify if you have got redis installed you can do this
php -m | grep redis
Create a file PHP with echo phpinfo(); in it and see if the module is showing up. If you do not see the module then it is not being loaded correctly.
In the PHP5.3 and Amazon Linux AMI (Same as Centos OS 5)
install libs
yum install php-pear php-devel make gcc wget
install redis
cd /opt/
mkdir /opt/redis
wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz "or last version"
tar -zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make
make install
install php-redis by pecl
pecl install redis
configuration option "php_ini" is not set to php.ini location
You should add "extension=redis.so" to php.ini
reload the web service httpd
service httpd reload
verify that the extension has been installed
php -m
[PHP Modules]
bz2
...
**redis**
...
[Zend Modules]
Download the proper library file according to your server environment( ex. x86). also, check for your PHP is thread-safe or not and download the Redis library accordingly. then place the library file inside the extension folder. you need to mention the library inside your php.ini as given below.
extension=redis.dll
then restart the server once, and check it's working properly or not.
if you have command line PHP, you can check it in the command line PHP as,
php r("print_r(get_loaded_extensions());")

unable installing php extensions from source

I installed php 5.3.10 from source and it runs fine. But when i tried to install extensions from source packages like xdebug and mongo i get the following output after running phpize
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
configure.in:3: warning: prefer named diversions
configure.in:3: warning: prefer named diversions
Notice that these are just warnings not failure. So i continued and used ./configure and then make and then make install. A message came like this
Installing shared extensions: /usr/local/lib/php/extensions/debug-zts-20090626/
I checked in the above directory and the extension's shared object(.so) was there. So i added the path to my php.ini and restarted apache. But the extension is not installed.
I googled it and found that the warnings come because the phpize path is not correct. I checked this by
phpize --help and it shows the path /usr/local/bin/phpize
also php-config version is 5.3.10
php-config -v and it shows version 5.3.10
Whats wrong and what is meant by those warnings?
EDIT:
When i try to install these extension from pecl i can install them successfully and i can see them installed in the output of phpinfo()
But i cant install mcrypt via pecl so i need some way of installing extensions using phpize
i know it's a old question, but to solve this problem, just run the command ./configure with the option "--with-php-config".
./configure --with-php-config=/usr/bin/php-config

Categories