I have Memcache installed and working for PHP apps run through Apache (v2.2) but when I try to run a .php file in the command-line i get this error:
Fatal error: Class 'Memcache' not found in /usr/local/Matters/app/matters-common/connection.php on line 94
Line 94 is:
$memcache = new Memcache;
Other info:
CentOS 5.2
PHP 5.2.5 (cli) (built: Feb 20 2008 21:13:12)
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Apache v2.2.8
Presumably you have separate php.ini files set up for apache and the command line (cli).
If so, you need to add the following to your cli php.ini file:
extension=memcache.so
On Ubuntu it's in /etc/php5/cli/php.ini
If it's working then memcache should appear in the list of modules if you run php -m on the command line.
Alternatively, you can create a file /etc/php5/cond.d/memcache.ini with the same contents.
It is possible that you have a separate php.ini file for CLI mode. This file might not include memcache extension.
I did have this kind of error and I also did php -i | grep memcache and it says memcache is enabled, but my solution that solved the problem was when I edited the php.ini, i simply modified the extension_dir="./" line to the full path of the extensions directory which now looked like this, extension_dir="/usr/local/lib" -- you need to check where the extension directory of the php reside and make sure memcache.so is there..
then i simply restarted httpd and alas the problem is gone.
you can check the detailed steps here:
http://joemarie-aliling.com/223/php-programming/php-memcache-not-found-problem/
For simplicity sake I used:
php -c /etc/php.ini ./cli-script.php
If you do not know which php.ini your command line is using, type php -i. You will get a long list of settings, where somewhere near the top of the list you will see which php.ini is being used:
Configuration File (php.ini) Path => /Applications/MAMP/bin/php/php5.3.6/conf
Loaded Configuration File => /Applications/MAMP/bin/php/php5.3.6/conf/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
Related
Hello I'm using latest version of Laravel, PHP 7.1.9 and MySQL 5.7.19. I'm also using WAMP stack.
When I run the command:
php artisan migrate
I get the following error:
I googled a lot and I' m 100% sure my php.ini file does not have the driver line commented out and the driver is properly working, as seen here:
The driver is obviously present:
Also the path to extension dir is absolute:
extension_dir ="c:/wamp64/bin/php/php7.1.9/ext/"
What else can I do? This thing is driving me crazy
There are 2 php.ini files in the WAMPServer implementation.
One for APACHE which is the one accessed from the menu system and one in each wamp\bin\php\phpx.y.z folder
As you are using the PHP CLI you have to check that all the required extensions are also activated in PHP you are using for the CLI wamp\bin\php\phpx.y.z
Do this from the command line
php --ini
It should show you something like this
Configuration File (php.ini) Path: C:\WINDOWS
Loaded Configuration File: C:\wamp64\bin\php\php7.0.29\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Look at this param Loaded Configuration File: to see which php.ini file you should be checking.
This post may also be useful to you for making a batch file to run from the command prompt to switch easily from one version of PHP CLI to another from the command window How To Run PHP From Windows Command Line in WAMPServer
I have installed Phalcon on my vServer and it seems to be loaded,
but if I try to run website I get an error
PHP Fatal error: Class 'Phalcon\\Config\\Adapter\\Ini' not found in /home...
php -v
PHP 5.6.10 (cli) (built: Jun 11 2015 08:33:51)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
I followed the instructions on Phalcon website.
If I list php modules using php -m Phalcon is listed, I don't have
any errors, just don't know why it's not working!
Also, Phalcon is not listed on phpinfo(); page.
looks like you changed the config for the php console client but that config is not the same for the php module in apache.
Review what config is being loaded for apache module
When installing phalcon in order to get the extension working make sure to restart nginx / apache2, and if you are running PHP as a module php5-fpm service as well.
$ sudo service nginx restart
$ sudo service php5-fpm restart
I encountered the same problem and the reason is that I recompiled php with source code but not recompiled phalcon again after that. I solved that by compiling phalcon again with the correct phpize.
Sometimes when phalcon is installed, it creates a separate .ini file for itself and adds the extension therein. This is common in mac and linux OS. In such situation, type php --ini on the terminal. You should see an out put similar to the following...
Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File: /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed: /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini,
/usr/local/etc/php/5.6/conf.d/ext-phalcon.ini
As you can see, phalcon created the /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini file.
SOLUTION:
Open the file using sudo nano /usr/local/etc/php/5.6/conf.d/ext-phalcon.ini, copy the line in which the extension is loaded and paste in /usr/local/etc/php/5.6/php.ini if you are using XAMPP, copy the line to /Applications/XAMPP/xamppfiles/etc/php.ini Restart your server and check if that works.
I recently installed xdebug on my server but restricted it's use to our test site, which uses it's own php.ini file.
For example, the test sites php.ini is located at:
/home/test_site/public_html/subdomain_name/php.ini
Inside this php.ini file I have the below for xdebug:
[XDebug]
zend_extension = /usr/local/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = /home/test_site/xdebug
xdebug.profiler_output_name = "cachegrind.out.%s-%u.%h_%r"
Now, the thing is, xdebug works fine, no problems.
However, on our main site, which also has it's own php.ini file, which is located for example at:
/home/main_site/public_html/php.ini
Inside this file I have nothing for xdebug in there.
Now, I recently setup a cron in cpanel for the main site such as:
php -f /home/main_site/public_html/cron_jobs/main_cron.php > /home/main_site/public_html/logs/main_cron.log 2>&1
Now, upon checking the output of the cron inside the log file I get the output:
Failed loading xdebug.so: xdebug.so: cannot open shared object file: No such file or directory
Why am I getting this error when the main site shouldn't even be loading xdebug?
Even though you have the two sites split up and using two different php.ini files, CRON will still use whichever php.ini file the PHP-CLI is configured to use. So, to figure out which php.ini CRON is using, this is the command to use:
php -i | grep php.ini
If PHP-CLI happens to be using a php.ini file that you didn't expect it to be using (such as /usr/local/lib/php.ini) then that will be the key to figuring out why you're seeing Xdebug errors in the logs.
It turns out that the /usr/local/lib/php.ini file had these two values set:
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20090626"
zend_extension = "xdebug.so"
That was causing the error from the php script that was run by CRON (i.e. PHP-CLI) because zend_extensions need the full path to the module. This is also stated in the Xdebug documentation: http://xdebug.org/docs/install
So, to get rid of the error, just comment out that line (or just remove it). You could also comment out or remove the extension_dir line as long as you are not loading any other modules such as:
extension = memcached.so
Sometimes might be difficult from where the XDebug library is loaded since it can be done either by specifying the path in php.ini or by adding the lib in mods-available.
Firstly, run:
$ sudo grep 'xdebug' -r /etc/php/*
This will give you the files that loads the extension.
Now identify which php.ini is in use:
$ php -i | grep php.ini
This will give you the php version in use (in case you have multiple php versions). Now link the php version with the result from the first step.
Now, either you have to comment out the line where the xdebug extension is loaded or remove the xdebug.ini file (that loads the extension) from /etc/php/x.x/mods-available (where x.x stands for the php version in use).
I tried all the processes mentioned above and for this and many similar after Googling around, I still ended up with this error
$ php -i | grep php.ini
Failed loading /usr/lib/php/20200930/xdebug.so: /usr/lib/php/20200930/xdebug.so: undefined symbol: zend_get_properties_for
Configuration File (php.ini) Path => /etc/php/7.3/cli
Loaded Configuration File => /etc/php/7.3/cli/php.ini
I resolved this by Updating Xdebug using Pecl. If you do not have it installed following the instruction here
$ pecl install xdebug
Now I changed my xdebug.ini file. You can use
$ locate xdebug.ini
Add zend_extension = usr/lib/php/20180731/xdebug.so to the file.
xdebug.ini
[xdebug]
zend_extension = usr/lib/php/20180731/xdebug.so
The latest version of Xdebug 3.0.4 still uses these usr/lib/php/20180731/xdebug.so but if you try to use $ locate xdebug.so you would see a different file location.
Php output the right Zend Extensions
$ php -v
PHP 7.3.27-9+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 23 2021 15:10:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.27-9+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
For the record, in Linux Mint and I think in some Ubuntu Systems. To change the php.ini it's the best to go to /etc/php/7.0/cli/conf.d and look for the xdebug.ini and you must change the lines said in the post above mine.
I tried below in Linux and worked,
you can use the below command to locate the xdebug.so file path
locate xdebug.so
ex: /usr/lib/php/20160303/xdebug.so
use below command to locate the current php.ini file
php -i | grep php.ini
ex:
Configuration File (php.ini) Path => /etc/php/7.1/cli
Loaded Configuration File => /etc/php/7.1/cli/php.ini
After that add below xdebug configuration to both cli and apache2 folder's php.ini files with correct xdebug.so file path.
vi /etc/php/7.1/cli/php.ini
vi /etc/php/7.1/apache2/php.ini
[xdebug]
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
Finally, restart the apache2 server
sudo service apache2 restart
Make sure that you are using the correct xdebug port in your editor!
Cheers! :)
I've got a problem with a cron.
This is the line:
09,39 * * * * root [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete
When this line works i'm taking a mail from my server:
PHP Warning: Module 'ionCube Loader' already loaded in Unknown on line 0
[Tue Nov 05 03:09:01 2013] [warn-phpd] The ionCube PHP Loader is disabled because of startup problems. (pid 32450)
When I remove the line related with ioncube from php.ini, site is not working. And when I remove the line from ioncube.ini ioncube doesn't work.
If I remove this job what happens? Any other solution?
I'm using Debian 6 x64, PHP Version 5.3.3-7
Thanks.
Your post suggests that you have referenced the Loader in two php.ini files, the main php.ini and a second one (ioncube.ini) located in an additional ini scan directory. The ionCube Loader must be installed only once, and ideally referenced in only one php.ini file.
Produce phpinfo() output from both the webserver and CLI PHP used by the cron job, and check to see if the referenced php.ini locations are the same. Also check that the PHP version is the same as sometimes it isn't due to PHP being updated incorrectly/incompletely on a server.
If the PHP version is the same and there is a common php.ini file being referenced, such as /usr/local/lib/php.ini, then that's the best place to place the zend_extension line for ionCube. You can use -c to specify the location of a php.ini file if needed.
If the PHP version is different, you must not use the same php.ini file that references the Loader as you need different Loaders. Use a different php.ini file for the CLI case and reference its location with -c. Consider fixing the installation to use the same PHP version for web and CLI though.
Probably not the case here, but if you have edited only one php.ini file to reference the Loader, it would suggest that the php.ini file is being read twice. This is a flaw in PHP and can happen if the main php.ini directory is also one of the additional scan directories.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
While I am debugging PHP Script in Eclipse, it doesn’t load mysql extension
How can I make phpunit scan the /etc/php5/cli/conf.d directory for ini files?
I am using phpunit, but it is very time-consuming to configure correctly. One issue I just encountered is that ini files for my php extensions do not seem to get loaded properly, when I Lauch phpunit as a "Run Configuration" from within Eclipse.
I basically followed this tutorial: http://pkp.sfu.ca/wiki/index.php/Configure_Eclipse_for_PHPUnit
When run from within eclipse (Menu Run.../Run Configurations...), then
the directory
/etc/php5/cli/conf.d
which is linked to
/etc/php5/conf.d/
is not parsed.
Thus, for example, file
/etc/php5/conf.d/curl.ini
is ignored.
I have to add the one-liner to the ini file
echo "extension=curl.so" >> /etc/php5/cli/php.ini
which seems to solve the problem, but it is counterproductive, because it breaks modularization (and will be gone after the next distri / php upgrade)
To find this issue, I modified phpunit.php
by adding a call to phpinfo() to the beginning of the file.
Here's the output.
PHP Version => 5.3.10-1ubuntu3.4
System => Linux wb3 3.2.0-31-generic #50-Ubuntu SMP Fri Sep 7 16:16:45 UTC 2012 x86_64
Build Date => Sep 12 2012 18:58:31
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /tmp/zend_debug/session6700026373526677062.tmp/php.ini
Scan this dir for additional .ini files => (none)
Additional .ini files parsed => (none)
When I inspect /tmp/zend_debug/session6700026373526677062.tmp/php.ini:
using
grep -C 2 extension
I got no output.
After adding extension=curl.so to /etc/php5/cli/php.ini
the curl extension is loaded when I run the phpunit Eclipse-Run-configuration
But the result is different when I run phpunit from the command line.
Now I get
phpunit --debug --verbose MyClass
PHP Warning: Module 'curl' already loaded in Unknown on line 0
Update: (no answers yet)
I found a workaround for my problem:
I created a custom php.ini file in the filesystem, that contains all includes appended, and within Eclipse Preferences for PHP, I create a new configuration for the php5 interpreter, using my special-purpose php.ini.
Within Eclipse Run-Configuration Menu, , setting the Config Dialog Box, I simply point to the new php5-configuration.
But this does not solve the problem, so I'm still looking for answers. Is it an eclipse problem or a phpunit - problem? I have no clue at this time.
This is an expected behavior of Eclipse PDT. For more information, see the similar question and my answer.