1

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.

slhck
  • 223,558
  • 70
  • 607
  • 592
pixel 67
  • 133
  • 8
  • 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. – Tamara Wijsman Dec 08 '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 08 '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 08 '12 at 11:57
  • You need to run PHP through `gdb`, [see this](https://bugs.php.net/bugs-generating-backtrace.php). 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... – Tamara Wijsman Dec 08 '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 08 '12 at 13:21
  • @nikhil thanks man, I'm going to learn more about the command line before I do something like this again :) – pixel 67 Dec 08 '12 at 19:34
  • Don't worry about screwing up a few times, all of us have done it some time or the other. It's how we learn. – nikhil Dec 09 '12 at 08:56

1 Answers1

1

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.

slhck
  • 223,558
  • 70
  • 607
  • 592
  • I was using MAMP before, taking the next steps, I need to learn more about the command line – pixel 67 Dec 08 '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 08 '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? – Tamara Wijsman Dec 08 '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 08 '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 08 '12 at 12:12
  • You cannot simply copy the `/usr/bin/php` file. There is more to a complete PHP installation than that. You cannot get back to the original version without reinstalling OS X or getting the original PHP framework files from an installation disc ([as explained here](http://superuser.com/a/227653/48078)). In the future, please [edit] your question with important new information or where exactly you're stuck. This comment thread is becoming quite large… – slhck Dec 08 '12 at 12:15