The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   OS X Developer (http://hintsforums.macworld.com/forumdisplay.php?f=27)
-   -   Install php6 on a mac (http://hintsforums.macworld.com/showthread.php?t=89448)

TruthSeeker 05-09-2008 01:12 PM

Install php6 on a mac
 
Hi,

i'm using a standard macbook with osx 10.5.2 .
I'd like to be able change my default (Leopard's) php installation with php6 .
As php6 is still under development so i need to compile and install a snapshot. I've looked around for tutorials and even tried a few but ended nowhere.

Can anyone give or indicate me a good walkthrough?

Thanks

acme.mail.order 05-09-2008 07:58 PM

Why do you want PHP6? As you say, it's still under development and won't be available on web hosts for a long time to come. PHP5 is only now becoming widely available, and I didn't start coding PHP5-specific stuff until last month.

Server software (inlcuding PHP) isn't upgraded "just because" - you wait until a stable release has been updated a few times.

Newbish 05-10-2008 09:57 AM

Truthseeker,

When building PHP6 from the source code, use ./configure --prefix=/usr/local/php6 as part of your configuration. Then complete the build with make and make install

Note: you may have to create the "local" directory in "/usr".

Second, set your PATH variable so that the system looks into the new php ../bin directory before going on through the rest of the usual locations. Do this by manually typing these two lines on the command line prompt:

[/b]
> bash
> PATH=/usr/local/php6/bin:$PATH
[/b]

The "bash" creates a new shell for you, and the PATH setting tells the operating system to look in that directory for a command before looking in the other places. So whenever you type "php" on the command line, it will run your PHP6 installation instead of using the built-in PHP.

When you exit the shell by typing exit, then the PATH will be returned to normal and your system will be returned to normal. This is important as it ensures if things aren't working correctly, you can quickly put things back to normal.

It is important to build your alterations into the /usr/local directory and then change the path to look there first. This way, if things aren't working, you didn't overwrite the original routines built into the system, and you can put things back to normal just by removing the path reference.

You could make the change a bit more permanent by editing the bashrc file, but I recommend against that until you are certain that the installation is stable and working correctly.

I had Apache 2, MySQL 5, and PHP5 all working together on production servers a good three years before they were accepted, even while PHP5 was still in development, because PHP5 offered far better MySQL integration and the OOP structure made it easier and better to program database accesses. It is also fun and educational, and it gives you a look at what is to come.

TruthSeeker 05-10-2008 11:23 AM

Hi again, i've tried using ./configure --prefix=/usr/local/php6 --with-apxs2=/Library/bin/apxs --enable-sockets --with-xml --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql but i'm getting "checking for location of ICU headers and libraries... not found
configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
"

I've been using php5 specific tech for some time now.
I'm currently developing the base for a php development toolkit, with a similar simple plugin structure as wordpress, but using classes, autoload() and namespaces (only existent on php 5.3 and php6).

I chose php6 so i could also check out the new features to come.

Thanks for the temporary PATH tip, will apache recognize it for it's php calls?

Newbish 05-10-2008 09:50 PM

According to the PHP6 meeting notes (link at the bottom of this page) the ICU libraries are supposed to- or will be included with the PHP6 source code.

Try adding the tag --with-icu to your configure prefix. Don't specify a path for it, let the configure script go look for it. If it still fails, you may have to use Google to search for the ICU libraries and manually build them into your system.

Apache should see your new PHP installation. If not, there is some further tweaking that may need to be done. Best way is to use the phpinfo function:
Code:

<?php
echo phpinfo();
?>

...and then call it via your web browser and see what it reports.

When in doubt, read through the INSTALL file included with the source code and see if it offers any more insight. Another consideration would be to try ./configure --help and see what options are available to you. I haven't tried to build PHP6 (yet) myself, so I can't offer any more advice than all that.

TruthSeeker 05-13-2008 06:45 AM

stuck again :/
 
ok, i've managed to install icu from source, now i'm getting a problem on libxml2.

i've used
$ ./configure --prefix=/usr/local/libxml2 --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc
$ make
$ sudo make install

and when i'm configuring php 6 i get:
Configuring extensions
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr/local/libxml2
checking for xml2-config path... /usr/local/libxml2/bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed. Please check the config.log for details.


on the config.log :
configure:20184: checking whether libxml build works
configure:20211: gcc -o conftest -gstabs -fvisibility=hidden -no-cpp-precomp $

-lm -lm -licui18n -licuuc -licudata -lm -licuio -lxml2 -lz -liconv -l$
configure: failed program was:
#line 20200 "configure"

Newbish 05-13-2008 08:27 AM

Before trying to build libxml2, try locate libxml2. Leopard already has it built into the system. (Located in /usr/include).

When building PHP6, in the configure line, just add --with-libxml2 without giving a specific path (unless it fails without the specific path). Unless you have a specifically built library you want it to use, let configure go looking for what it needs. I've had a lot of issues where the build was failing because I was being too specific in my settings.

Also, do the entire build process as the root user. It helps avoid issues when your regular user needs something it may not normally have access.

Building development-level software can be a bit frustrating at times and requires an iterative building process. There are times that the author of the software already has all the libraries he needs to build his software, and it doesn't occur to him that someone else might not. You just have to keep configuring and making adjustments until you have everything lined up.

TruthSeeker 05-13-2008 12:00 PM

ok, it was already installed as you said.

$ ./configure --prefix=/usr/local/php6 --with-apxs2=/usr/sbin/apxs --enable-sockets --with-xml --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-icu-dir=/usr/local/icu --with-libxml-dir=/usr/include/libxml2

still getting:
Configuring extensions
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr/include/libxml2
checking for xml2-config path... /usr/bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed. Please check the config.log for details.


on the log :
configure:19997: checking libxml2 install dir
configure:20026: checking for xml2-config path
configure:20184: checking whether libxml build works
configure:20211: gcc -o conftest -gstabs -fvisibility=hidden -no-cpp-precomp $

-lm -lm -licui18n -licuuc -licudata -lm -licuio -lxml2 -lz -licucore $
configure: failed program was:
#line 20200 "configure"


i've tried to --disable-libxml but i get configure: error: DOM extension requires LIBXML extension, add --enable-libxml

Newbish 05-14-2008 09:25 AM

Like I said earlier:

Instead of --with-libxml-dir=/usr/include/libxml2

Try using --with-libxml. Don't specify a path to it and see if the configure script moves forward. I've had issues like this with other things in the past.

(Well, actually I said "--with-libxml2". When all else fails, take a look at the configure options with ./configure --help.)

TruthSeeker 05-14-2008 09:34 AM

i get checking libxml2 install dir... no and still fails :(

Newbish 05-14-2008 10:12 AM

Okay, then don't have that directive at all, then. Remove --with-libxml and see if the build goes through.

TruthSeeker 05-14-2008 10:36 AM

nope, i think i've tried all the possible combinations of ./configure lol. I think i clearly must give it the folder with --with-libxml2-dir=/local/includes/libxml2 - seems to work this way, but still says testing libxml2 fails :/

I'll ask for a more detailed walkthrough on php.net's forums, i'll post back here if i get it to work ;)

Newbish 05-14-2008 12:02 PM

One last test I like to use: will it build with no options set except the --prefix=/usr/local?

If it does, then try an XML function to see if you get an exception.

navaho 05-14-2008 09:18 PM

You've put more than one path to libxml2 in your posts. Typos, or just a "misremember" I assume?

Try this: If it's /usr/local/libxml2 just go with --with-libxml=/usr/local

or /local/includes, whichever is the actual correct path. You've used both.

TruthSeeker 05-15-2008 05:58 AM

yep, i've tried it both ways, with and without ....../libxml2 and keeps failing, /usr/local/libxml2 was my installation, then i found out /usr/include/libxml2 is already installed on the mac.

Nobody answers on the php forums :s

Newbish 05-15-2008 08:16 AM

Quote:

Originally Posted by navaho (Post 469642)
You've put more than one path to libxml2 in your posts. Typos, or just a "misremember" I assume?

:) Yeah, that's happened, too.:rolleyes:

Actually, what happens is sometimes when the configure file generation isn't correct. Had this happen for two of the MySQL 5 and one of the PHP5 development builds. This is why they want people to download the development sources and try to build them. While a developer knows how his machine is configured, he can't even begin to guess how someone else's machine will be configured. As we install one program or another, things get added to an OS that might create a configuration that the configure script can't work out.

If you've tried everything you can think of and it still doesn't build, try configure without any options other than the prefix path. If it still errs out, then it is possibly a problem with the build.

Basically, send a message saying you are having build difficulties, where it bombs out and any messages you get. You might get a response asking for more detail, or about a week later new source code might appear that builds on your system without errors. Just be patient and remember that PHP6 is in alpha. :)

The PHP and MYSQL source codes have been the most reliable builds over the years. We can attribute that solidity with the fact that many people such as yourselves have tried the development builds and reported back any issues. So if you feel like you are getting nowhere, keep in mind that you truly are accomplishing something even when things break.

navaho 05-15-2008 02:04 PM

Quote:

Originally Posted by Newbish (Post 469684)
:)

The PHP and MYSQL source codes have been the most reliable builds over the years. We can attribute that solidity with the fact that many people such as yourselves have tried the development builds and reported back any issues. So if you feel like you are getting nowhere, keep in mind that you truly are accomplishing something even when things break.

That's very well said.

TruthSeeker 05-16-2008 11:25 AM

I've already tried with prefix only, breaks with icu, then with icu path breaks at libxml2 :/

I'll report a "bug" at php.net with the issue

Daio 05-20-2008 10:38 PM

The issue is *almost* certainly to be with the ICU libraries. Did you install them in a non default directory? I'm guessing by the location of your libxml2 libraries that the ICU libraries were installed in /usr/local/icu?

When the ICU libraries are built their install name is the file only rather than the default behaviour of gcc's linker of an absolute path to the library. Which means that during PHP configure the conftest executable that gets built to test libxml fails as it can't find the ICU libraries that it was linked against.

There are a couple of different ways to deal with the problem, the easiest is to just rebuild the ICU libraries with the default prefix however, my preference is to make a small modification to the ICU config file (<icu-source-directory>/config/mh-darwin) then rebuild the ICU libraries. The main reason being is this method allows me to install multiple different version of the ICU libraries and link to which one I require.

The change to the file is to find line:
Code:

LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR)
-Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name $(notdir
$(MIDDLE_SO_TARGET))

and change it to:
Code:

LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR)
-Wl,-current_version -Wl,$(SO_TARGET_VERSION) -install_name
$(libdir)/$(notdir $(MIDDLE_SO_TARGET))

That line is quite near the top of the mh-darwin file, so should be quite easy to find.

All your doing by making that change is to add the full path to the final install location of the library to the library's install name.

Once the ICU libraries are rebuilt and reinstalled then PHP's configure should complete and pass the testing of a working libxml2. If either ICU or libxml2 are installed in non-default directories then you will have to specify the full path to their inistall directories with --with-icu-dir=/full/path/to/icu/directory and --with-libxml-dir=/full/path/to/libxml2/directory when calling configure.

Other options to work around the problem include either permanently setting DYLD_LIBRARY_PATH as an evirnonment variable with the value of the full path to the ICU library directory. Or you could add the "-headerpad_max_install_names" to LDFLAGS for configure then run install_name_tool on any of the PHP binaries built that link to the ICU libraries. But personally I find those types of solutions a bit clunky and cumbersome.

TruthSeeker 05-23-2008 06:31 AM

To make it clearer:

MySQL is installed on /usr/local/mysql
PgSQL is installed on /usr/local/pgsql
ICU is installed on /usr/local/icu (compiled from source)
libxml2 is installed on /usr/include/libxml2
apxs2 is on /usr/sbin/apxs

I've used $ ./configure --prefix=/usr/local/php6 --with-apxs2=/usr/sbin/apxs --enable-sockets --with-xml --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-icu-dir=/usr/local/icu --with-libxml-dir=/usr/include/libxml2

Still got error on libxml2.

Could it be ICU is not working correctly for some reason? how can i test it?

Daio 05-23-2008 08:08 AM

Forgive me if it's a silly question but did you "make clean" the ICU source before recompiling?

You can quickly check that the ICU libraries have their full paths in the install name from the terminal by typing..
Code:

otool -L /usr/local/icu/lib/libicui18n.dylib
The resulting output should list a handful of libraries and each of them should have their full path rather than just the library name.

I also doubt that /usr/include/libxml2 is the actual base install location for libxml2, that directory should just contain the libxml2 header files. It's more likely that if your relying on the system's own libxml2 then the install directory is probably /usr

With your above configure line what is the error(s) from config.log?

TruthSeeker 05-26-2008 07:41 AM

Code:

$ otool -L /usr/local/icu/lib/libicui18n.dylib
-bash: otool: command not found

nothing is returned by $ locate otool

Xcode is not installed... downloading... i'll post back here.

TruthSeeker 05-26-2008 09:36 AM

ok,
Code:

$ otool -L /usr/local/icu/lib/libicui18n.dylib
libicui18n.38.dylib (compatibility version 38.0.0, current version 38.1.0)        libicuuc.38.dylib (compatibility version 38.0.0, current version 38.1.0)
        libicudata.38.dylib (compatibility version 38.0.0, current version 38.1.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

I've retried
Code:

$ ./configure --prefix=/usr/local/php6 --with-apxs2=/usr/sbin/apxs --enable-sockets --with-xml --infodir=/usr/share/info --mandir=/usr/share/man --sysconfdir=/etc --with-mysql=/usr/local/mysql --with-pgsql=/usr/local/pgsql --with-icu-dir=/usr/local/icu --with-libxml-dir=/usr/include/libxml2

(...)

Configuring extensions
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... /usr/include/libxml2
checking for xml2-config path... /usr/bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed.  Please check the config.log for details.

The config log is available here. :/

Daio 05-26-2008 10:20 AM

From the output from otool it shows that the ICU libraries do not contain their full paths in their install name, which suggests that either you didn't "make clean" before rebuilding the ICU libraries or you haven't applied the suggested modification to the correct file in the ICU config directory?

The output should be....
Code:

$ otool -L /usr/local/icu/lib/libicui18n.dylib
    /usr/local/icu/lib/libicui18n.38.dylib (compatibility version 38.0.0, current version 38.1.0)
    /usr/local/icu/lib/libicuuc.38.dylib (compatibility version 38.0.0, current version 38.1.0)
    /usr/local/icu/lib/libicudata.38.dylib (compatibility version 38.0.0, current version 38.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)

You could try temporarily telling dyld where to look for the ICU libraries. From the terminal window....
Code:

DYLD_LIBRARY_PATH=/usr/local/icu/lib:${DYLD_LIBRARY_PATH}
export DYLD_LIBRARY_PATH

And from the *same* terminal window rerun configure. If it now passes the libxml build test then then that's a good indicator that the problem is with the install name of the ICU libraries. Note, even if configure completes at this stage you will not be able to build working PHP binaries. I'd go back to the ICU source directory and from the terminal type..
Code:

make clean
Then ensure the edit/modification suggested earlier is applied to the config/mh-darwin file, then re- configure and make the ICU libraries, after running "make install" rerun otool on one of the ICU libraries.

If you are absolutely sure that that you did previosuly "make clean" and apply the edit to the mh-darwin config file then perhaps ICU uses a different config file when building on Leopard? In which case someone else will need to give you some pointers as I don't currently have access to a machine running Leopard.


All times are GMT -5. The time now is 05:56 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.