I have installed and working PHP53 from source.
PATH is set in ~/.profile
like this: export PATH=$PATH:/usr/local/php53/bin
$ php -v # works good
BUT:
$ sudo php -v # sudo: php: command not found
I needed to run sudo composer self-update
, and it gave me a message:
/usr/bin/env: php: No such file or directory
$ composer -v # works good (installed globally by this manual https://getcomposer.org/doc/00-intro.md#globally
In short:
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
I have similar problem with Apache22 apachectl
, but I am using full path to run with sudo. But it is a workaround, and I'd like to know, how to make it work in common.
The problem is that $ sudo php -v
and sudo composer self-update
DOES NOT WORK.
UPDATE: I added to /root/.profile new path to PHP53:
# ~/.profile: executed by Bourne-compatible login shells.
export PATH=$PATH:/usr/local/php53/bin
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
Then I rebooted OS, and here are results for various tests:
$ echo $PATH # /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/apache2_2/bin:/usr/local/php53/bin
$ php -v # works, as before
$ sudo php -v # "sudo: php: command not found"
$ sudo su
# echo $PATH # /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games , i.e. "export PATH=$PATH:/usr/local/php53/bin" did not have effect on $PATH.
# php -v # "The program 'php' is currently not installed. You can install it by typing:
apt-get install php5-cli"
# . /root/.profile
# php -v # "PHP 5.3.29 (cli) (built: Sep 24 2015 13:05:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
BUT:
$ sudo php -v # still, "sudo: php: command not found"
As a little relief,
$ sudo /usr/local/php53/bin/php -v # is working
PHP 5.3.29 (cli) (built: Sep 24 2015 13:05:17)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2014 Zend Technologies
Seems like we have at least two problems:
- export $PATH in /root/.profile does not have effect (tested after OS reboot!)
- even when I do
# . /root/.profile
,sudo php -v
still does not work.
OS: Ubuntu 12.04 with last updates.