7

I have a strange problem with PHP version when using CLI. When I login as root and use: php -v I get an info that php is running in CLI mode which is fine, but as soon as I use sudo php -v I get php-fcgi version which brakes some of my code. The thing is I have Supervisor set up to call some php proccess(Laravel queue) and unfortunately it gets called in fcgi mode so some of variables are not available, thus my code breaks. Is there any workaround for this ? I am using CentOS 6.5.

3 Answers 3

1

@blackhatblade above is most likely coorect. To test this, log in as both your root and non root user and try this command

# which php

$ which php

"which" should tell you the path. If they are different, an unqualified "php" will execute the first one found in each list of directories.

It's also possible that your root user may have a shell "alias" remapping php. to check this, try the command "alias"

Finally, it's possible your php executable is a wrapper of some kind, which checks for root execution environment, and shunts you to the fcgi version. Check that by examining the fully qualified path you found in the first step from "which," and see if it's a shell script doing something sneaky based on who is running it.

0

The contents of $PATH are probably different when sudoing. Locate the correct binary and give a full path.

If your php program is called directly, edit it's shebang to the full path of the cli binary.

0

You should set path variable in in /etc/environment. & make sure both root & normal user have same PATH variable.

Try sudo nano /etc/environment

Make backup before editing the file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .