Reputation: 5084
Hi im trying to execute php file from bash script
#!/bin/sh
php ./func.php
and func.php
file looks like
<?php
echo "php file";
And as output
PHP Warning: Module 'apc' already loaded in Unknown on line 0
EDIT: And maybe U can also tell me how to pass parameter to php file ??
Upvotes: 3
Views: 2064
Reputation: 25575
In my case (on Ubuntu, a Debian based Linux variant), I had two copies of apc.ini
in /etc/php5/conf.d/
. I had one that I had put there when I first installed apc. I also found a symlink from /etc/php5/conf.d/20-apc.ini
to ../mods-available/apc.ini
.
It appears that some upgrade of php, enabled this module the "Debian way" (with a symlink). I deleted my copy of apc.ini and I am now just using the one that is symlinked to mods-available
.
Digging further, there are command line programs that should be used to enable and disable PHP modules under Ubuntu and Debian. Here are the commands to enable and disable APC:
sudo /usr/sbin/php5enmod apc # Creates the symlink in /etc/php5/conf.d that enables APC
sudo /usr/sbin/php5dismod apc # Deletes the symlink in /etc/php5/conf.d that disables APC
Upvotes: 0
Reputation: 2652
All of the answers above hinted at what was going on, but it was the fact that there was a separate apc file that was being loaded, so simply grepping for "extension=apc.so" didn't uncover the issue.
php --info | grep -i apc
PHP Warning: Module 'apc' already loaded in Unknown on line 0
Additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini
So since the module was being loaded, you just simply need to remove the "extension=apc.so" from both your apache and cli php.ini configs.
Upvotes: 1
Reputation: 9671
Find out which php.ini
is being used in CLI mode:
php --info
and check the content of that php.ini
for a double declaration of extension=apc.so
Upvotes: 2
Reputation: 26974
This error is related to your PHP configuration, not to your code.
This can be fixed in your php.ini
, check this thread: http://blog.ciuly.com/my-server/php-warning-module-apc-already-loaded-in-unknown-on-line-0/.
Upvotes: 3
Reputation: 288260
An error in Unknown on line 0
means that your configuration is defective (this has nothing to do with bash - directly running the program should yield the same message).
In your case, you have two instances of extension=apc.so
in your php configuration. Use
grep apc.so /etc/php5/cli/ -r
to find these.
Upvotes: 8