Why would I see PHP NOTICE and ERRORs when running a script as a regular user, but not as root?
As far as I can tell, there's no difference between the error reporting or message redirection between users. They both use the same PHP ini.
However, when I run a script as a regular user, I get tons of NOTICES, when run as root, I get none. When starting PHP interactive mode as a regular user, I get two PHP Warnings that 'memcache' and 'xmlwriter' are alre开发者_高级运维ady loaded; when starting as the root user, I get no warnings.
I know that I should be fixing the warnings, not "making the warnings go away;" that's on the ticket. The question is, Why are the users treated differently? Why does a regular user get notices and warnings, but root does not, even if their error reporting are the same?
It's likely that the actual PHP binary that you're executing is different due to differences in your $PATH
. You may have a copy of PHP installed in /usr/bin
that uses shared modules for memcache, and another in /usr/local/bin
that has it statically linked.
Both executables may reference /etc/php.ini
for their configuration. If the configuration file is telling PHP to try to load a shared module, the copy that has it statically linked will generate the errors you're getting.
Try the command which php
as the normal user and root, which should report back the location of the PHP executable. You can also say echo $PATH
as each user to see the directories it's searching. You may need to add/remove a directory from the $PATH
, which you should be able to do in your ~/.profile
file.
Something is different in the environment.
What if you try investigating like this:
$ php -i > mortal
$ su php -i > root
$ diff mortal root
精彩评论