0

I am trying to create new yii application on Ubuntu by calling:

sudo yii-project/framework/yiic webapp yiidemo 

from my htdocs dicectory(XAMPP). The message I get is:

/usr/bin/env: php: No such file or directory 

PHP is installed though. 'php -v' yelds:

PHP 5.5.11 (cli) (built: Apr 9 2014 14:29:14) Copyright (c) 1997-2014 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies 

My PATH looks like that('echo $PATH'):

/home/alan/home/alan/netbeans-8.0/bin/netbeans/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/lampp/bin 

'php' seems to be in /opt/lampp/bin so the last entry.

Any advice on how to make it work and get rid of the error would be greatly appreciated :).

7
  • Could your sudo be changing PATH on you, like it's sometimes known to on Ubuntu? Commented Apr 29, 2014 at 15:11
  • In my case 'sudo echo $PATH' returns the same string as 'echo $PATH'. Commented Apr 29, 2014 at 15:14
  • Out of interest, what happens if you try sudo php yii-project/framework/yiic webapp yiidemo? Commented Apr 29, 2014 at 19:17
  • Good bet :). sudo: php: Command not found. I get the same for sudo php -v(while php -v works fine). But then sudo echo $PATH is exactly the same as echo $PATH. Commented Apr 29, 2014 at 19:39
  • 1
    Given that this seems to be a Unix environment problem, you might find more luck asking the basic question about sudo php -v not working somewhere like serverfault.com Commented Apr 29, 2014 at 20:32

1 Answer 1

1

Solution:

1) Sudo PATH and user PATH differ. That's why 'sudo php -v' doesn't work.

User's path:

echo $PATH /home/alan/home/alan/netbeans-8.0/bin/netbeans/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/opt/lampp/bin 

A proper way to echo sudo's path:

sudo /usr/bin/printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin 

2) I've installed PHP from repositories. I can now call 'sudo php'.

sudo apt-get install php5-cli 

Thanks Matt and guys from Ubuntu forums(spjackson & SeijiSensei)!

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

1 Comment

Cool; glad you got it sorted.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.