3

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 ??

6
  • 2
    Have you tried checking the cli configuration file (on a Ubuntu system it would e.g. be located in /etc/php5/cli/php.ini) for references to module apc? And is this your complete func.php file? Looks incomplete to me (at least closing ?> is missing) Commented Jan 2, 2012 at 11:51
  • 3
    @nyarlathotep Leaving out the closing ?> is a best practice. Commented Jan 2, 2012 at 11:52
  • @phihag: thanks for the hint! been writing php code for a long time but didn't know that - seems I should read up on best practices :) Commented Jan 2, 2012 at 11:54
  • I thought that ?> its not so important as it is in PHP. Thanks Commented Jan 2, 2012 at 11:55
  • 1
    @skowron-line Please ask a second question on how to get parameters. That way, this question remains uncluttered, and future seekers will have an easier time reading questions and answers. Commented Jan 2, 2012 at 12:11

5 Answers 5

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks +1 ! Do you have any idea where this duplicate line comes from ? I also had an ...active=1 line duplicated in the ini file.
3

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/.

Comments

2

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

Comments

1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.