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.

I deleted my system PHP on OS X Lion by installing a fresh copy of PHP 5.4. I can't seem to restore it with Time Machine. What do I do next? When I type which php I still get /usr/bin/php.

But when I type php -v I get:

error 2992 segmentation fault

Sometimes the #2992 changes. Now when I try to view any pages with PHP I see the source code instead of the page.

share|improve this question
1  
Can you get a PHP with debugging information and start it with gdb? If you can't you could try a different version of PHP assuming there is a bug with the one you're trying to install. –  Tom Wijsman Dec 8 '12 at 11:53
    
I really want to get the system php re installed, what if I upgrade to mountain lion will that restore the system php? –  pixel 67 Dec 8 '12 at 11:55
    
GNU gdb 6.3.50-20050815 (Apple version gdb-1822) (Sun Aug 5 03:00:42 UTC 2012) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries ..................... done –  pixel 67 Dec 8 '12 at 11:57
    
You need to run PHP through gdb, see this. Have you tried installing a different version of PHP? Consider MAMP, which slhck referred you to, which sounds like the preferred way to go if you don't want to go through a reinstall. Although a reinstall sounds safe as slhck stated it... –  Tom Wijsman Dec 8 '12 at 12:08
    
Its nice that you don't want to use MAMP and learn more about the command line. I'll suggest next time you install it in someplace in your home directory and then change your path to use your binary first. A similar approach is taken by homebrew you should give that a look. Always better to use a package manager than compiling and installing packages, it should be a last resort. All the best. –  nikhil Dec 8 '12 at 13:21
show 2 more comments

1 Answer

up vote 1 down vote accepted

If you really managed to not only delete /usr/bin/php (which could be easily restored from a backup or another Mac), then your only easy option is to reinstall OS X. Doing so, it will leave your user files in place (i.e. the one in /Users) but it will overwrite all system components, including the packaged versions of PHP. Upgrading OS X is also possible in this case – it will have the same effect.

You can reinstall OS X Lion or Mountain Lion by booting into Recovery. Just hold CmdR while startup and reinstall OS X. Make sure you take a backup of your entire system before though.

In the future, if you want to work with other PHP versions, consider using MAMP, a standalone package that comes bundled with various PHP versions to choose from (including 5.3 and 5.4), which does not interfere with your system binaries and frameworks.

share|improve this answer
    
I was using MAMP before, taking the next steps, I need to learn more about the command line –  pixel 67 Dec 8 '12 at 12:01
    
Well, the lesson learned here I guess is that anything you can do with sudo is potentially harmful to your entire system. You could of course try to restore to a Time Machine backup state that was before the incident and lose the files you've created in between. –  slhck Dec 8 '12 at 12:03
    
@slhck: Is there anything different about OS X which doesn't allow the user to debug PHP's segmentation fault or install a different version of PHP? It sounds to me like an upgrade of OS X would do more bad than good, does it really do nothing else but replace the files? –  Tom Wijsman Dec 8 '12 at 12:05
    
@pixel67 So your external drive doesn't contain a backup from before the incident? (By the way, if a Time Machine volume is full, it'll just delete old unused files, but you can still continue to use it). If you already attempted a full system restore from Time Machine and that didn't work, something else is broken, but we'd need way more information about that. –  slhck Dec 8 '12 at 12:09
    
I do have a backup, when I followed the directions for the time machine and came to the copy the old php file (which I got from a friend) id didn't work –  pixel 67 Dec 8 '12 at 12:12
show 2 more comments

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.