Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Execting php-scripts from the command line now does not work. When executing a script starting with #!/usr/bin/env php. I get this error message:

env: php: No such file or directory.

So it seems I can not run php as an executable script with /usr/bin/php.

I think what's causing my problem is that I followed these instructions for allowing MAMP’s copy of PHP to run from the terminal.

sudo mv /usr/bin/php /usr/bin/php-old

appears not to be working. php is not renamed.

If I should add something to my path. What should I add? When running echo $PATH:

/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/X11/bin 

Btw (don't know if it is related): MySQL is running but I can't access http://localhost/ when running:

sudo apachectl start
share|improve this question
    
What happens when you enter which php? Does it find your PHP installation? Does it work for every user account, or only for yours? –  Daniel Beck Jul 7 '11 at 9:01
    
I did sudo mv /usr/bin/php-old /usr/bin/php. No I get /usr/bin/php. –  r4. Jul 7 '11 at 9:06
add comment

2 Answers

up vote 2 down vote accepted

That's why you should never mess around with /usr/bin, but keep local installations of binaries.

If you did the following

sudo mv /usr/bin/php /usr/bin/php-old

you will be able to revert by just doing

sudo mv /usr/bin/php-old /usr/bin/php

then /usr/bin/env php should work.


If you decide to continue with the MAMP installation, you can of course move your default php to php-old. But then you also need to execute the following after moving php to php-old:

sudo ln -s /Applications/MAMP/bin/php5/bin/php /usr/bin/php

in order to have the php shipped with MAMP available under /usr/bin/phpagain.

But I can't promise that will work as expected at all. Again, you shouldn't move stuff in /usr/bin.

share|improve this answer
add comment

You can just use the path of your PHP installation directly in the script.

#!/Applications/wherever/it/is/you/installed/php
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.