Jump to content

What is the correct way to update PHP4 on OS X?


Recommended Posts

I read a number of pages on how to install PHP on Mac OS X. They all assume I am installing PHP support for Apache, which is not the case for me - I just want to be able to re-learn PHP (used it a few years ago on an XP system.) PHP does appear to be enabled on my MacBook Pro - when I do a whereis, it tells me /usr/bin/php. I downloaded the source for php-4.4.7, followed the compile directions, and it all worked with no errors. Based on the compile output, the files were installed to /usr/local/lib/php. When I type php -v, I get

 

PHP 4.4.4 (cli) (built: Jan  8 2007 15:02:29)

Copyright © 1997-2006 The PHP Group

Zend Engine v1.3.0, Copyright © 1998-2004 Zend Technologies

 

I bought my system in September 2006. I don't know what application I installed that put PHP 4.4.4 on my system (perhaps Apple Software update?) Shows how much I pay attention I guess.

 

I know zero about Darwin, *NIX, etc. Am I supposed to replace the existing php or put it in another directory and redirect to it? How do I do either one of those? <g>

 

-Z

Link to comment
Share on other sites

Installing into /usr/local/lib/php isn't right. That wont be in your path. Hence when you do php -v you still get the old version.

 

What ./configure options did you use to compile?

 

Am I supposed to replace the existing php or put it in another directory and redirect to it?

 

Up to you. I usually just replace.

Link to comment
Share on other sites

I followed the directions here:

 

http://developer.apple.com/internet/opensource/php.html

 

shell> cd php-4.3.4

shell> ./configure --with-apxs

shell> make

shell> sudo make install

 

 

I figured that following the directions on Apple's page would be a good starting point, but here I am. Which option do I need to change the installation dir? I paged through the Configure options on ActiveState, but nothing appeared to relate to where PHP is dumped once it's compiled.

 

I know, these are basic n00b questions...

 

-Z

Link to comment
Share on other sites

Well, for starters, ./configure --with-apxs compiles php as an apache module. So, unless you have the apache web server already installed (which you said you don't want for whatever weird = "They all assume I am installing PHP support for Apache, which is not the case for me") it should have generated errors.

 

Anyway. The option --prefix=/usr/bin tells the .configure script to install the (you guessed it) /usr/bin. This is the typical location.

 

The last time I compiled php purely for the cli I used....

 

./configure --prefix=/usr --sysconfdir=/etc --with-config-file-path=/etc \
--with-zlib --enable-bcmath --with-bz2 --enable-exif --with-gettext \
--enable-mbstring --with-ncurses --with-readline --with-sqlite --enable-sockets \
--without-pear--enable-cli --disable-dom --disable-cgi

 

This configuration required that I had already installed the dependency libxml. This configuration may not be any good to you but It gives you the idea... you really need to read through ./configure --help quite thoroughly.

 

PS: After looking at my Gentoo machine and seeing how it handles php, it seems it uses --prefix=/usr/lib/php5 as an install dir. I guess, this would be one way to have mutiple versions of php on the same machine. Havent looked into how its all linked together, but really, unless you specifically want multiple versions, I would stick with the standard --prex=/usr/bin.

Link to comment
Share on other sites

Ok... it is simply linked. If (as you say) your compile went ok, this should get you the latest php. I would make a backup of /usr/bin/php first if it already exists.

 

sudo ln -s /usr/lib/php/bin/php /usr/bin/php

Link to comment
Share on other sites

I understand that I have a lot of reading to do. I appreciate your help with this seemingly simple thing.

 

I tried using --prefix=/usr/bin, but ended up with:

 

Installing PHP SAPI module:      cgi

Installing PHP CGI into: /usr/bin/bin/

Installing PEAR environment:      /usr/bin/lib/php/

[PEAR] Archive_Tar: upgrade to a newer version (1.3.2 is not newer than 1.3.2)

[PEAR] Console_Getopt: upgrade to a newer version (1.2.1 is not newer than 1.2.1)

[PEAR] HTML_Template_IT: upgrade to a newer version (1.1 is not newer than 1.1)

[PEAR] Net_UserAgent_Detect: upgrade to a newer version (2.0.1 is not newer than 2.0.1)

pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)

[PEAR] PEAR: upgrade to a newer version (1.5.0 is not newer than 1.5.0)

[PEAR] Structures_Graph: upgrade to a newer version (1.0.2 is not newer than 1.0.2)

Installing build environment:    /usr/bin/lib/php/build/

Installing header files:          /usr/bin/include/php/

Installing helper programs:      /usr/bin/bin/

  program: phpize

  program: php-config

Installing man pages:            /usr/bin/man/man1/

mkdir: /usr/bin/man: File exists

mkdir: /usr/bin/man: Not a directory

make: *** [install-programs] Error 1

 

 

Trying to use /usr/bin/php seemed to work, but when I tried to run php -v I was told -bash: /usr/bin/php: is a directory. Restarted Terminal, now I have -bash: php: command not found. whereis says it's in /usr/bin/php

 

I'm ready to admit defeat. I guess I'm not supposed to do this. :/

 

-Z

Link to comment
Share on other sites

What is the full ./configure options you are using?

 

Also, I'de be pretty care full about attempting this over and over, your going to end up with bits and pieces of php all over the place. manually compiled / installed programs can be a nightmare to remove unless your tracking where things go.

Link to comment
Share on other sites

./configure --prefix=/usr/bin

 

If I can get that much to work, I'll experiment with other options, but so far I can't even get a basic install to work. It installs, but I can't actually run php - it keeps saying it can't find it.

 

Another thing... on all the sites I am reading, it says to use /usr/local, but you said don't do that.

 

-Z

Link to comment
Share on other sites

Sorry, think Ive made major typo in my second post. I meant to say --prefix=/usr (as shown in my example).

 

Another thing... on all the sites I am reading, it says to use /usr/local, but you said don't do that.

 

This is personal preference. Normally applications installed by the systems package management software are installed into /usr. /usr/local is reserved for applications installed manually.

 

As I don't use a package manager on the systems I compile manually I just use /usr for everything. I am the package manager.

Link to comment
Share on other sites

Okay, I got it to work but I had to cheat. I was getting myself confused over file / directory, so I opened /usr/bin in Finder. There was a php directory, so the build couldn't put a php file there. I deleted the stuff I did tonight and started over. The only way I could make it work was to compile to a temp directory and then manually copy the php binaries to /usr/bin. It now shows the correct version.

 

I did compile a copy of php5 to /usr/local, but it isn't seen by anything. Being new to OS X, I don't know how to adjust the "path" so the OS knows which one to look at.

 

Probably better leave well enough alone for tonight though. Thank you for your patience.

 

-Z

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.