Page 1 of 1

Sudo php

PostPosted: 30. January 2020 18:29
by youms
I have set /opt/lampp/bin as environment variables
I can't use php in sudo mode, "command not found". Can i use the php in xampp to compile files from terminal ini root mode? I do not want to install default php on ubuntu.

Re: Sudo php

PostPosted: 31. January 2020 10:27
by Nobbie
youms wrote:I have set /opt/lampp/bin as environment variables


What does that mean? What did you do exactly?

Re: Sudo php

PostPosted: 31. January 2020 10:45
by youms
I set this in my environment path so that I could use the Php that is installed with XAMPP in any terminal I open (/opt/lampp/bin)
I could execute basic Php commands like Php app/console to use Symfony frameworks. Unfortunately I can't use that same Php with sudo.
Sudo php gives me as output "Php not found"

Whereas if I install Php with sudo apt install php7.2-cli, sudo php will work great.

Re: Sudo php

PostPosted: 31. January 2020 12:36
by Nobbie
That is a linux problem (not Xampp). Sudo uses a so called "secure_path", configured in /etc/sudoers. It does not use PATH variable. See /etc/sudoers and read the manual about "sudo".

Anyway

Code: Select all
sudo /opt/lampp/bin/php


should do it as well.