2

I had PHP version 5.4 installed on my Mac 10.9 machine and wanted to upgrade to 5.6.

I downloaded the source files and ran ./configure, make and make install. I looked and it seems to have compiled and installed successfully, but it installed itself into /usr/local/bin. The old version of PHP is installed in /usr/bin.

When I run php, the /usr/bin location is used, since /usr/bin comes before /usr/local/bin in the $PATH. I would like to use the new version.

Should I just replace the old version of PHP in /usr/bin with the version in /usr/local/bin? Or should I delete them from /usr/bin altogether?

It's a little tricky because the 5.6 install also installed some other things, like a new version of perl and pecl and a couple other helper binaries (including php-config and phpize). Some of those (the last two) were already present in the /usr/bin folder, but perl and pecl were not. Should I move all the new things to /usr/bin?

Lastly, why is it that the newer one installed in /usr/local/bin but the old one did not? Is the distinction important? Did the PHP team decide to move it for some reason? Or was it just in /usr/bin because it came with my system, whereas the downloaded update gets put into /usr/local/bin?

And does the location of php.ini depend on any of this?

closed as too broad by Braiam, jordanm, Michael Homer, jimmij, Anthon Jan 18 '15 at 4:28

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Do not touch anything. Delete, move or otherwise. Why do you have the older version of php, and how you installed it? Isn't more easier just point whatever software to use the one in your /usr/local directory? – Braiam Jan 17 '15 at 23:51
  • @Braiam The older version of PHP comes pre-installed on Mac OS X. Is there any reason (dependencies, best practices, n00bness) you think I should "not touch anything"? The question is more about which directory is appropriate and what the best practices are for where to put PHP (/usr/bin vs /usr/local/bin). – AmadeusDrZaius Jan 18 '15 at 0:04
  • @Braiam Actually I was wrong - the original version of PHP seems to have been installed by me as well. So I guess it doesn't really matter. If anything's broken by moving it, I'll definitely find out! :P – AmadeusDrZaius Jan 18 '15 at 0:15
  • Generally, /usr/local/{bin,sbin} should come first in PATH. – jordanm Jan 18 '15 at 0:35
3

Generally, the /usr hierarchy is used for stuff coming from the OS vendor/site administrator, while /usr/local is used for things installed locally (for example on a network, /usr might be a NFS mount which is shared by several computers, while /usr/local is a local filesystem). This is why configure scripts usually install into /usr/local by default - to not break system packages. It is also the reason, why PATH should have /usr/local/{bin,sbin} before /usr/{bin,sbin}.

To change it, all you need to do (for a well behaved build system) is running:

./configure --prefix=/path/to/install/to

That saidm a lot depends what was the source of the older PHP version. Just overwriting it is not a good idea, since it may leave some files from the older version lying around (this is why using package managers is a Good IdeaTM). Thus unless you have a clean way of uninstalling the previous version, /usr/local might be slightly better. Another option would be (mis)using a separate hierarchy under /opt - e.g. installing into /opt/php5.6.

  • What I ended up doing was putting /usr/local/bin before /usr/bin in my PATH as you suggested. I also realized that I hadn't configured PHP correctly. I needed to include --with-apxs=/path/to/apxs when I ran ./configure so that the libphp5.so would get updated. With that, both Apache and the CLI are running PHP 5.6.4. – AmadeusDrZaius Jan 18 '15 at 7:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.