Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sneakyimp

macrumors newbie
Original poster
Feb 3, 2011
4
0
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:
Code:
My_Mac:mbam_v4 sneakyimp$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:.

And that there's a version of php living in /usr/bin:
Code:
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.
 
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.
 
What is your goal? Is it to run php from Terminal? To run php from shell scripts? To run php from a web server?

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.
 
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.
 
Thanks for the tips.

The man file doesn't offer anything about where files might be located except this tiny bit:
Code:
TIPS
       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:

              #!/bin/php
              <?php
               // 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)
Code:
My_Mac:/ sneakyimp$ sudo find * -name php
Password:
Developer/SDKs/MacOSX10.4u.sdk/usr/include/php
Developer/SDKs/MacOSX10.5.sdk/usr/include/php
Users/sneakyimp/src/php-5.3.2/sapi/cli/php
Users/sneakyimp/src/php-5.3.3/sapi/cli/php
usr/bin/php
usr/include/php
usr/lib/php
usr/local/bin/php
usr/local/include/php
usr/local/lib/php
usr/local/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:
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.