0

When logged in as root user, php loads the correct version which is php cli.

enter image description here

But when i do a sudo su < user >, php is is loading the cgi version which is breaking some of my applications that require php-cli version.

enter image description here

I tried changing the php-cgi to php-cli, but that just totally broke all my websites as I believe my cms websites require php-cgi to run properly.

How do I make php-cli as the default program when i do a sudo su user or sudo -i?

1 Answer 1

0

SUDO SU user only makes SU run as root, not the commands you execute in the context of the user. To force php to be executed as root, you need to use SUDO php, and the user also need to be added to sudoers. From a security perspective, I would not recommend the last part if the user is the same as the one running your CMS.

To allow the user pat to use SUDO php, add this to the end of sudoers with SUDO visudo:

# Allow the user pat to (sudo) execute /usr/local/bin/php
# as root without requiring user authentication.
pat ALL = NOPASSWD: /usr/local/bin/php

If the user pat is not the same user running your CMS, you could add pat to a group that has execute rights for /usr/local/bin/php.

If pat has execute rights and it's still not working, then make sure that pat has /usr/local/bin before /usr/bin in PATH.

You must log in to answer this question.

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