Showing posts with label PHP MAC OSX LEOPARD. Show all posts
Showing posts with label PHP MAC OSX LEOPARD. Show all posts

Saturday, 11 April 2009

Java: Bad CPU id in executable

Here is a weird one:

Recently i have been doing a lot of java work, and many of the packages I use need to have Java_HOME set. So normally
i just add this line to my /etc/profile


JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home; export JAVA_HOME


Works just fine on my Macbook, and my recent 2009 Mac Mini. However i have an older 2006 Intel Mac Mini, the older Core Duo type, rather than the newer Core 2 Duo versions. Its been out of action for a few months due to a failed Hard Drive, but recently I revived it by buying a suitable hard drive from PCWorld and attacking the machine with a putty knife. (upgrading the ram whilst i was in there).

Everything seemed to be working fine, re-installed the OS, and I took the opportunity whilst i had a virgin system to document and automate the installation of my EC2 management scripts. Everything swam along fine until I actually tried to use the EC2 management scripts where upon I got the dreaded message "java: Bad CPU Id in executable" WTF....

Googling the error did not seem to help, so back to the drawing board, and take a microscope to the machine.

I checked the target directories, they are fine, in the "versions" directory under the java framework I can see 1.42, 1.50 and 1.60. so what is happening.

The first clue is that the java preferences applet does not list the 1.6.0 version as available.... Hmm why not????

The second clue is that switching to version 1.5.0 in the JAVA_HOME statement makes it all work.

The answer is that Apple never released a 32bit version of Java 1.6, but to rub salt into the wounds they load a perfectly non-functional 64bit version onto all 32bit only boxes. Ouch...

Come on Apple, there is no reason to limit java 1.6 to 64bit only, and even if there is, why on earth load a nonfunctional 64bit framework onto 32bit machines?

Shakes head in amazement.......

Wednesday, 27 February 2008

Fixing Mac OS X Leopards abysmal PHP implementation

One of the unsung updates that occurred on OSX Leopard, was the introduction of Apache2 and PHP 5.2.4 as standard components for web page sharing. When you enable "Web sharing" on the Mac, you are essentially starting up a copy of the Apache workhorse on your system, enabled by OSX's unix underpinnings.

However in true Apple form, they seem to have gone out of their way to make life hard, and the default startup mode for the builtin apache system is as a 64bit application (on intel C2D+ hardware), making it difficult to use the provided PHP implementation "as is", if you need to load any extensions.

The issue stems from the choice of built in support on the Apple delivered php implementation. There are many deficiencies in the manifest of included options, of note is the lack of support for the PHP GD or GD2 module, used in many applications that required graphical output, PDFlib, libtidy and PEAR support are also highlighted by their absence.

Ok, no problem, down load the source for PHP 5.2.4. compile the extensions, and install them i hear you say....

Problem, on most recent Macs, the PHP implementation is also 64bit, a configuration that is not supported out of the box in the standard build options on PHP, and if that was not enough, many of the extensions you might want to install, are dependent on external libraries, not supplied by apple, and whose build environments also do not support creating the 4 way universal libs required to play nice across all the platforms Leopard runs on. Package managers such as fink or macports, hav'nt caught up with the need to supply 4 way fat binaries to cover all the possible platform variations.

Ok, no problem, I found this excellent tutorial on adding GD lib, , however try as i might, i could not get this to load, probaly again due to 64bit/32bit unhappyness. My foo is not enough........ :-( But it may work for you, and if GD is the only extension you need, then bobs your uncle.

Fortunately for those of use with more challenging PHP enviroment requirements Marc Liyange of http://entropy.ch fame has taken up the challenge and is producing a version of PHP 5.2.5 loaded for bear, which solves all of these build intricacies. Currently in beta 6, its works well on both my C2D macs and my G4 Macs.

However one word of caution, marc's installation process assumes that you have not yet enabled the on-board php implementation, if you have then you need to comment out the LoadExtension line you carefully uncommented to enable it, and trust to marc's magic installation of additional included conf files.

Oh, and another notable is that php.ini moves from /etc to /usr/local/php5/etc

More details of beta 6 can be found on this thread. http://www.entropy.ch/phpbb2/viewtopic.php?t=2945&start=0&postdays=0&postorder=asc&highlight=