![]() |
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 |
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. |
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. |
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? |
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:
<?phpWhen 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. |
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" |
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. |
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 |
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.) |
i get checking libxml2 install dir... no and still fails :(
|
Okay, then don't have that directive at all, then. Remove --with-libxml and see if the build goes through.
|
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 ;) |
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. |
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. |
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 |
Quote:
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. |
Quote:
|
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 |
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)Code:
LD_SONAME = -Wl,-compatibility_version -Wl,$(SO_TARGET_VERSION_MAJOR)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. |
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? |
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.dylibI 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? |
Code:
$ otool -L /usr/local/icu/lib/libicui18n.dylibXcode is not installed... downloading... i'll post back here. |
ok,
Code:
$ otool -L /usr/local/icu/lib/libicui18n.dylibCode:
$ ./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 |
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.dylibCode:
DYLD_LIBRARY_PATH=/usr/local/icu/lib:${DYLD_LIBRARY_PATH}Code:
make cleanIf 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.