I am using MAMP Pro to manage my development environments, the PHP is version 7.0.12 and is running in module mode.
I have added the pcntl module for PHP and have compiled it following the directions from this answer.
The pcntl.so file is in my /Applications/MAMP/bin/php/php7.0.12/lib/php/extensions/no-debug-non-zts-20151012 folder. Also, on my vhost I can output phpinfo() and verify that the extension is installed and additionally checked it by function_exists('pcntl_signal') which returns true.
However, I can't get it to work when running PHP from the terminal. I am using the one that MAMP installs and am invoking it through /Applications/MAMP/bin/php/php7.0.12/bin/php. However, I get the error that the function pcntl_signal does not exist.
Also running /Applications/MAMP/bin/php/php7.0.12/bin/php -i | grep pcntl doesn't output anything.
Is there a way to make the pcntl module available to PHP through the command line in addition to the one apache is using?
There are two separate ini files that MAMP uses for PHP.
One is editable through the GUI, the other needs to be manually edited. For this PHP version the extension must be added in /Applications/MAMP/bin/php/php7.0.12/conf/php.ini
After adding extension=pcntl.so into the above ini file, running php -i | grep pcntl will output
pcntl
pcntl support => enabled
Related
I have mediawiki on my local machine. I have php and php-mbstring installed. When I run phpinfo(), mbstring shows up. I have checked that I have mbstring.ini and mbstring.so, and they are on my machine.
When I run php maintenance/update.php I get this error:
Error: Missing one or more required components of PHP.
You are missing a required extension to PHP that MediaWiki needs.
Please install:
* mbstring <https://www.php.net/mbstring>
mbstring is installed and enabled, so I am not sure what to do here.
Versions:
php CLI: 7.4.5
php : 7.3.19-1
MediaWiki: 1.34.1
As has been said in the comments, you may have mbstring enabled only for your PHP backend, like php-fpm.
To make sure that mbstring is enabled for php-cli, type php -i | grep 'mbstring' in your console. If there is no output, php-cli has no access to mbstring. Alternatively, you can use phpquery -v 7.4 -s cli -m mbstring.
The best way to enable PHP extensions everywhere is to use sudo phpenmod mbstring. You can also check the existence and contents of /etc/php/7.4/cli/conf.d/20-mbstring.ini (extension=mbstring.so).
If you have build PHP from source for debug, then the location of .ini files may be different.
I've pasted the example from php.net for using memcached in php and I'm getting:
Fatal error: Class 'Memcache' not found
I have this in my php.ini:
[memcache]
memcache.hash_strategy = "consistent"
memcache.max_failover_attemps = 100
memcache.allow_failover = 1
Here's info from php -i and php -m respectively:
php -i | grep -i memcache
memcached
memcached support => enabled
libmemcached version => 0.37
Registered save handlers => files user sqlite memcached
php -m | grep -i memcache
memcached
So php seems to have loaded memcached as a module, and php info says that it is loaded and is using v .37. I have not tried yet via apache, I've only been using this through cli right now. Any thoughts?
There are two extensions for memcached in PHP, "memcache" and "memcached".
It looks like you're trying to use one ("memcache"), but the other is installed ("memcached").
Dispite what the accepted answer says in the comments, the correct way to install 'Memcache' is:
sudo apt-get install php5-memcache
NOTE Memcache & Memcached are two distinct although related pieces of software, that are often confused.
EDIT
As this is now an old post I thought it worth mentioning that you should replace php5 with your php version number.
I found solution in this post: https://stackoverflow.com/questions/11883378/class-memcache-not-found-php#=
I found the working dll files for PHP 5.4.4
I don't knowhow stable they are but they work for sure. Credits goes to this link.
http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip
http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip
It is the 2.2.5.0 version, I noticed after compiling it (for PHP 5.4.4).
Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP. Mirror links:
http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip
For OSX users:
Run the following command to install Memcached:
brew install memcached
The right is php_memcache.dll. In my case i was using lib compiled with vc9 instead of vc6 compiler. In apatche error logs i got something like:
PHP Startup: sqlanywhere: Unable to
initialize module Module compiled with
build ID=API20090626, TS,VC9 PHP
compiled with build ID=API20090626,
TS,VC6 These options need to match
Check if you have same log and try downloading different dll that are compiled with different compiler.
I went into wp-config/ and deleted the object-cache.php and advanced-cache.php and it worked fine for me.
I added the curl module in /etc/php/7.0/cli/php.ini :
extension = /usr/lib/php5/20121212/curl.so
but when I restart php and I do :
php -m
I get this error :
curl : Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20141010
These options need to match
I also tried :
apt-get install php5-curl
Curl is "already to the new version".
And phpinfo() tells php5 is running :
PHP Version 5.5.9
php.ini Path : /etc/php5/fpm
PHP Extension : 20121212
but when I check on the server with :
which php => /usr/bin/php (for php7)
php -v => PHP 7.0 (with a warning before "Unable to initialize module")
and if I remove curl.so in the php.ini above (the one of php7, at 1st line) the warning disapear.
---------------------------------------
so I added : extension=/usr/lib/php5/20121212/curl.so
in :
/etc/php5/fpm/php.ini
then I restart, but I still can't see this module :
And here the error saying this module is still missing :
So, if you're trying to add the module to webserver's PHP, which is in your case PHP5, you need to add that module to /etc/php5/fpm/php.ini (based on your previous question where you stated that you use NGINX+PHP-FPM).
If you want to add it to the CLI version - you're doing it wrong, cause you're adding PHP5 module to PHP7 - that won't work, you need to install php7-curl and it will auto-add itself where needed.
To elaborate somewhat more. Your phpinfo() tells you that your INI path is in /etc/php5/fpm:
PHP Version 5.5.9
php.ini Path : /etc/php5/fpm
PHP Extension : 20121212
Hence, to add any extensions to that particular PHP - just add them to /etc/php5/fpm/php.ini. Note, you can not (or very rarely) add extensions from one version of PHP to another version of PHP.
I'll add a summary of what's happening on the OP's system for future reference then.
Basically, OP has 2 versions of PHP installed on the system simultaneously, PHP5 and PHP7 with an NGINX werserver with php-fpm extension.
His NGINX is configured to use PHP5, while CLI PHP defaults to PHP7.
The confusion with OP comes from the fact that on an Ubuntu system there's a clear difference between the PHP that's called from the CLI and the PHP that's used by webserver.
CLI tools are available per-version as /usr/bin/php5 and /usr/bin/php7, with one default link /usr/bin/php pointing to one particular version, in this case PHP7.
For the FPM module, there are 2 packages available php5-fpm and php7-fpm, with respective configs in /etc/php5/fpm/php.ini and /etc/php/7.0/php.ini.
For the CLI, there are 2 packages available as well - php5-cli and php7-cli, with respective configs in /etc/php5/cli/php.ini and /etc/php/7.0/cli/php.ini.
For curl extension, there's the same story, php5-curl and php7-curl. Extensions will be auto-wired to the needed INI files by the deb installer.
Installing multiple versions of PHP for fun can create this kind of confusion. :)
That means that your CURL module was compiled against a different version of PHP. Depending on your flavor of Linux (looks like Debian flavor) you might need to install a module
sudo apt-get install php5-curl
What about calling your hosting company to see what versions they have available and which one's your code are picking up?
Maybe they have some unique setup that's picking versions in a way you aren't picturing (one wouldn't picture.)
I need the MongoDB PHP driver on my CentOS 5.4 machine. My PHP version is 5.1.6. I downloaded the RPM and installed it. That created several files in /usr/bin directory. I copied
/usr/bin/mongo
to
/usr/lib/php/modules
which was what extension_dir showed on doing phpinfo();.
I also added
extension=mongo.so
in /etc/php.ini.
However on executing my PHP script, i still get
Mongo class not found.
What's going wrong here ?
Also, my phpinfo() shows PHP version 5.1.6 whereas running PHP from command line shows 5.3.3. Could anything be wrong with that ?
Thanks in advance.
You're saying your webserver and command line PHP report different versions. These are going to be installed in different locations, and their extensions are API incompatible with each other.
When you installed the php_mongo extension, it may have used the command line php to determine the directory to install the extension to.
Make sure you have the correct php_mongo for the php version of your webserver, and it is in the correct extensions directory. (get the directory from the php.ini returned by phpinfo())
I hope you realise PHP 5.1 is also many years out of date. Unless you have a specific reason to use a version that old, you should also look at upgrading to a more recent version.
Edit:
Just read your comment "I must also mention that /usr/bin/mongo is a binary executable file but its not having a .so extension. Im copying it as is to /usr/lib/php/modules"
No no no! :)
This is the mongo command line client. This is not the PHP extension!
You can run a find /* -name "mongo.so" to see where the installer put the file, this will probably also give you an indication of which version of PHP it was installed for.
It looks as though you are confusing the RPM-packages for the MongoDB server with the requirements to install the MongoDB PHP driver. The PHP driver provides access to the server from your PHP applications, and does not install any command line tools.
restart httpd !
yum service httpd restart
I've been trying to get DocBlox working on windows. I'm running wamp server with PHP version 5.3.9. I've enabled XSL and its showing in phpinfo as well as if I run a test script, XSLTProcessor is available.
I installed DocBlox from PEAR. It runs, however I get the error that the XSL writer was unable to find your XSLTprocessor.
Any ideas? Thank you!
The error that you are receiving means that php does not recognize the xsl extension. Php has got a separate ini file for CLI and web; and I presume that you have enabled the xsl extension for apache only.
You can verify this by executing php -i in your command prompt and check if the xsl extension is enabled there. If not then add your dll to the right config for your WAMP.