Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to install Symfony on Mac OS X Lion. Apparently, as MAMP was already installed on my computer, there was a problem with the "timezone" field in the php.ini file. I can't remember exactly the error but basically, Symfony installation required a timezone like "Europe/Paris" but MAMP apparently changed that part.

Well, it's very vague but I've seen on the web that other people had the same issue. So I tried one of the solution I found (without success) but:

  1. It didn't work.
  2. I can not use the php command anymore ("-bash: php: command not found"). I can not remember the exact commands I did to go back.

Here are some potential relevant commands I found in my history and that correspond with the beginning of my problem, in this order:

sudo mv /usr/bin/php /usr/bin/php-old
sudo ln -s /Applications/MAMP/bin/php5/bin/php /usr/bin/php
rm /usr/bin/php-old
sudo cp php.ini.default /etc/php.ini
rm php.ini but I don't know anymor in which repertory I was. 
sudo mv /usr/bin/php-old /usr/bin/php
share|improve this question
echo $PATH outputs: /Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin:/usr/sbi‌​n:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/usr/texbin By looking very far in he command history, I found this command: "rm /etc/php.ini". It can't be good right? Do you think that it could be the origin of my problem? If so, do you know how I can fix it? Thank you slhck – Aurelien Porte May 14 '12 at 20:19
up vote 1 down vote accepted

What have you done?

By executing

sudo rm /usr/bin/php-old

you could have deleted your original PHP installation after renaming it. If you just executed the command without sudo, you probably weren't able to remove it since the file is owned by root, not your normal user.


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

And check if entering php -v works. If yes, everything's fine. If not, your system php is gone. Try to restore it from a backup.

How to restore php from a backup:

Here's how, if you have Time Machine:

First, note the name of your Time Machine volume. Then get the name of your computer, and also find out how your boot volume is called. These are labeled 1, 2 and 3 in the following screenshot, so the Time Machine volume is named TimeMachine on my computer (this is called charon), and the boot volume is called Macintosh HD.

Now, in the terminal, type:

cd "/Volumes/TimeMachine/Backups.backupdb/charon/Latest/Macintosh HD/usr/bin/"

Replace the bold names with the ones you got above. If that succeeded, while you're still in the same Terminal folder, run:

sudo cp php /usr/bin/php

This will copy php back from your Time Machine volume to your local hard drive. You're done. Check by typing php -v if everything worked.

If you somehow backed up or overwrote your latest backup, you can restore from the oldest backup as well.

Enter the following, replacing the names like we did before:

cd "/Volumes/TimeMachine/Backups.backupdb/charon"


cd $(ls -r1 | tail -n 1)

This will go to your earliest backup. Now enter (and don't forget to replace the name of the volume):

cd "Macintosh HD/usr/bin"

And copy back php, similar to the above command:

sudo cp php /usr/bin/php

If you want to change php.ini

Normally, MAMP will not use /etc/php.ini, but will use its own php.ini file placed inside the MAMP application folder. So you have to change that if you want to modify MAMP behavior.

If you want to use MAMP's php

Note: This is optional.

If you really want to use MAMP's php over the system one, do the following (unless you have a file called .profile, then use this):

open -e ~/.bash_profile

TextEdit will open and you'll edit your bash profile, which sets important envorinment variables. Here, add the following line:

export PATH=/Applications/MAMP/bin/php5/bin/:$PATH

Then, save the file, exit, and in the terminal, run the command:

source ~/.bash_profile

Now, run which php, and it should point to the MAMP folder. The output of php -v should also now be from MAMP's php.

share|improve this answer
ouch, please don't ask me why but it seems that I also did "rm usr/bin/php-old". That is probably why I couldn't find the file and that your solution didn't work for me... I do have a file /usr/bin/php though. PS: I am about to edit my question with part of the history that seems relevant – Aurelien Porte May 14 '12 at 20:33
Please check my updated answer. Report any error messages you get or if you have additional questions. – slhck May 14 '12 at 21:12
Ok so I did delete the php system AND its copy (I won't use sudo anymore, I promise...). I temporarily replaced it with MAMP php before finding a system version (I don't know how to get this file from a Time Machine back up...) Do you think that it could work if someone under lion send me a copy of his /usr/bin/php system file? Another question: if you know a very good place on the web where I could learn the most important principles of linux, I would be pleased to hear that from you! I'm curious but I have a big lack of basis in this domain. Thanks a lot slhck – Aurelien Porte May 15 '12 at 11:34
You can restore it from Time Machine. I updated my answer again with instructions on how to do that. It would also work if someone with Lion sent you the file (in that case, ping me and I'll show you how). As for learning Linux, there are plenty of basic tutorials online. I can't recommend any, but I've found one by Google which seems pretty nice. – slhck May 15 '12 at 11:52
Everything worked perfectly! (Except that even with \, I didn't manage to handle the spaces so I changed the name of the computer) I have my php system file back! Thanks so much! Hope being able to help others like you did soon ;) – Aurelien Porte May 15 '12 at 12:44

Your Answer


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.