I'm trying to update where the command line gets the location of the php binary:

webserver: /usr/bin

cli: /opt/local/bin/php

Where can I edit so when I do 'which php' it shows me /usr/bin/php


In your .bashrc

export PATH=/usr/bin:$PATH
  • Didn't change. I logged in as my normal user and was at the home directory, did nano .bashrc and added the above line (file was empty) I also checked .bash_profile and it had export PATH=$PATH:/usr/bin:(other paths here) – rschmitty Sep 22 '11 at 23:47
  • Remove the .bashrc change, and edit your .bash_profile instead so that /usr/bin is first. – suihock Sep 23 '11 at 0:07

It won't change the actual location, but you can make a symbolic link (shortcut) using the ln program.

sudo ln -s /opt/local/bin/php /usr/bin/php

That makes a shortcut from /opt/local/bin/php to /usr/bin/php. It's cleaner and more straightforward than having duplicate files or adding a directory to your PATH, in my opinion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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