Upgrading PHP to latest, removing old PHP

Discussion in 'Mac Programming' started by sneakyimp, Feb 17, 2011.

  1. sneakyimp macrumors newbie

    Feb 3, 2011
    I have managed to download and build PHP 5.3.3 from source on my 10.5.8 system, but there are still vestiages of the old version of PHP on this system -- mostly command-line stuff.

    For example, on the command line, instead of just typing "php file.php", it launches an older version of php. To get my latest running, I must type the full path to my new php: "/usr/local/bin/php file.php"

    I see that my path is this:
    My_Mac:mbam_v4 sneakyimp$ echo $PATH
    And that there's a version of php living in /usr/bin:
    My_Mac:mbam_v4 sneakyimp$ ls -l /usr/bin/php
    -r-xr-xr-x  1 root  wheel  14869808 Oct  6 16:57 /usr/bin/php
    Note that the item there is a full-blown file and not a symbolic link. I'd like to delete it but I'm a bit afraid to break things -- and I'm also wondering if there might be other pieces to this old PHP somewhere.

    I'm wondering anyone can give me a comprehensive set of steps to get rid of all OLD versions of php and get my new one hooked in at all the right places. Any help would be much appreciated.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    What is your goal? Is it to run php from Terminal? To run php from shell scripts? To run php from a web server?

    Maybe you should just put /usr/local/bin first in your PATH (for any of the above goals), so the php located there is always found first.

    Then the task becomes "How do I change the PATH?", and the answer to that depends on what your goal is.
  3. sneakyimp thread starter macrumors newbie

    Feb 3, 2011
    I have also installed Apache 2.2.15 on that machine. Come to think of it, I have vestiges of an old apache in there too -- typing "apache ctl start" typically launches the wrong apache so its "/usr/local/apache2/bin/apachectl start".

    Its primary function is to be my web development server so I guess Apache would be first. At the same time, I develop a lot of PHP daemon scripts which I launch from the command line -- and convenience is important to me. It's tedious to type the entire path every time I want to launch a PHP script via CLI.

    My goals:
    1) To remove every vestige of the old PHP and apache from my machine -- even at the risk of breaking things
    2) To have a path var that is as bog-standard as you can get -- which for me means it's as similar as possible to a fresh install of debian linux.
    3) To live happily and confidently knowing that when i type "php file.php" it will be the version of PHP that I frequently recompile when I need to change settings and I build from source and use "make install" to install it.

    I hope that's not asking too much.
  4. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    Then I would read the man page for the pre-installed php, and its config files, to find where its supplementary files are. Once all that's been located, unlink it all.

    Finally, add a hard-link between /usr/local/bin/php and /usr/bin/php. Or just cp it over to /usr/bin. Why? So there's a php located in the pre-installed location.

    Oh, and do a backup first, unless you like working without a safety net.
  5. sneakyimp thread starter macrumors newbie

    Feb 3, 2011
    Thanks for the tips.

    The man file doesn't offer anything about where files might be located except this tiny bit:
           You can use a shebang line to automatically invoke php from scripts. Only the CLI version of PHP will ignore such a first line as shown below:
                   // your script
    But that appears to be from the standard man page on php as opposed to anything apple-specific. A search for files/directories named 'php' yields the following (which I've pruned for irrelevant stuff)
    My_Mac:/ sneakyimp$ sudo find * -name php
    /usr/local/ is apparently where stuff goes when you compile PHP from source and run "make install". /usr/bin appears to be the mac default. :confused:

Share This Page