Topic : Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard

This question is answered. "Helpful" answers available: 2 . "Solved" answers available: 1 .



            Permlink
            Replies : 12 - Pages : 1 - Last Post : Oct 23, 2009 5:08 PM by: Shane Depner1
LarryJ

Posts: 1
From: Minnesota
Registered: Jun 30, 2008
Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard
Posted: Jun 30, 2008 7:37 AM
 

The first part of this tutorial is roughly based on the Moodle Docs "Step by Step Installation on a Mac OS X 10.5 Server"
http://docs.moodle.org/en/Step_by_Step_Installation_on_a_Mac_OS_X_10.5_Server

Installing Entropy php5 with GD support on Mac OS X 10.5 Leopard Server:
===============================================
The following steps are performed on a standard clean installation of Leopard Server with Apache 2 and php5 enabled.

1. Download and move the entropy php5 package to /usr/local
Direct link:
http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz
Search the forums for latest package:
http://www.entropy.ch/phpbb2/viewforum.php?f=2
Or download from the command line
$curl -O http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz

Unpack the file:
$tar -xzf php5-*-beta.tar.gz

Move the file:
$sudo mv php5 /usr/local/
If you downloaded it to the Desktop:
$sudo mv ~/Desktop/php5 /usr/local/
If you downloaded it to the Downloads folder:
$sudo mv ~/Downloads/php5 /usr/local/

Set ownership to root:
$sudo chown -R root:admin /usr/local/php5

2. Edit the httpd.conf file for Apache 2 using nano (or your preferred text editor)

$sudo nano /etc/apache2/httpd.conf

You will now scroll down until you see:
LoadModule php5_module libexec/apache2/libphp5.so

Use a # to comment out the line (CaSeSeNsItIvE!):
#LoadModule php5_module libexec/apache2/libphp5.so

Now add a line right below it so the Web server will find your new installation:
LoadModule php5_module local/php5/libphp5.so

Save the httpd.conf file.

Now create and edit the php.ini file:

Copy the template file:
$sudo cp /usr/local/php5/lib/php.ini-recommended /usr/local/php5/lib/php.ini

Now open the php.ini file in nano or your preferred editor:
$sudo nano /usr/local/php5/lib/php.ini

Now you may set your max upload parameters, etc.

N.B. If you need mysql enabled, scroll down and add this under the mysql section:

mysql.default_socket = /var/mysql/mysql.sock

Save the php.ini file.

Now restart the web server and uncomment the (remove the // before) phpinfo() command in the file /Library/WebServer/Documents/info.php

<?php
// You can use Server Admin to enable the Apache PHP module; it's disabled by default.
// You can uncomment the phpinfo() directive below to provide a default PHP info page
// but note that this displays information about your host's configuration.
phpinfo();
?>

http://your-server-address/info.php

You should see it running:
PHP Version 5.2.5
www.entropy.ch Release 6

And if you scroll down, you will find it has GD enabled.

Installing APC accelerator on Mac OS X 10.5 Leopard Server:
=====================================
This tutorial is base on the APC installation and the location of the php5 folder above!

Preamble:
There are dozens of people looking for this solution if you do a quick Web search. There are several pitfalls involved. First, Apache 1.3 is still in the same place as previous versions of Mac OS X server but Apache 2 is now enabled by default. That means you have to be very explicit about locations or Apache and PHP won't be able to find things...

First discovery: if you run the following command from the command line:
$echo $PATH
You will see:
/usr/bin:/usr/sbin:/sbin;/usr/loca/bin;/usr/x11/bin

This tells, in order, where the shell looks for an executable. It will run the first instance it finds, even if it's the wrong one. When you run phpize, it will run from /usr/bin/php instead of our new installation /usr/local/php5/bin. We will run the proper instance below.

OK, let's begin:

Start by downloading APC. I used APC-3.0.19 for this tutorial.
http://pecl.php.net/package/APC
Direct link:
http://pecl.php.net/get/APC-3.0.19.tgz

First I unpacked the file:
$cd ~/Downloads
$gunzip -c apc_x.y.tar.gz

Then, I moved it to the /usr/local/php5/bin folder:
$sudo mv ~/Downloads/APC-3.0.19 /usr/local/php5/bin/

Then I moved into the directory:
$cd /usr/local/php5/bin/APC-3.0.19

Here's the first 'gotcha':
Run the proper version of phpize:
$/usr/local/php5/bin/phpize

Here's the second 'gotcha':
Run the following configure command. Paste in the entire command. Be sure there are no line breaks in it:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure

After a couple of screens it will end with something about creating config.h

Next run make:
$make

After about a half a dozen screens of code you will see
"Build Complete.
Don't forget to run 'make test'."

The run make install:
$make install

Here's the next 'gotcha':
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20060613/
(The name of your folder may be slightly different.)

Note the path above. It's the WRONG place!!!! It should be in our custom install folder:
/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
(The name of your folder may be slightly different.)

The solution? Copy the 'apc.so' extension over:
$ cp /usr/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/apc.so

Now the last step. We have to edit php.ini again. Open the php.ini file in nano or your preferred editor:
$sudo nano /usr/local/php5/lib/php.ini

Comment out (add a semi-colon before)
;extension_dir = "./"

Then go down to the section labeled:
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

and a little lower where it explains how to add UNIX extensions, paste in the apc information as below:

; ... or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.

extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1

With any luck you now have GD and APC running on Apache2 with PHP5.

Restart the web server and uncomment the (remove the // before) phpinfo() command in the file /Library/WebServer/Documents/info.php

<?php
// You can use Server Admin to enable the Apache PHP module; it's disabled by default.
// You can uncomment the phpinfo() directive below to provide a default PHP info page
// but note that this displays information about your host's configuration.
phpinfo();
?>

http://your-server-address/info.php

You should see it running:
PHP Version 5.2.5
www.entropy.ch Release 6

And if you scroll down, you will find it has GD and APC enabled.

If something doesn't work, open the CONSOLE and look at
LOG FILES > apache2 > error_log
If you see the following warning, you didn't successfully move the apc.so module to the proper directory:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/apc.so' - (null) in Unknown on line 0

SECURITY WARNING
Comment out the phpinfo() command on your Web server when you are finished so the world doesn't have access to view your installation, paths, server info, etc.
//phpinfo();

XServe   Mac OS X (10.5.3)    

Luis Speciale

Posts: 1
From: France
Registered: Aug 31, 2008
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard
Posted: Aug 31, 2008 10:32 AM   in response to: LarryJ
 

Thanks for the post. I finally did it but with the cvs version

http://cvs.php.net/viewvc.cgi/pecl/apc/

At the left bottom of this page

Download GNU tarball

And I did everything like you said. APC is working now in my G5

With

PHP Version 5.2.5
www.entropy.ch Release 6

Universal Binary i386/x86_64/ppc7400/ppc64 - this machine runs: ppc64

apc

APC Support enabled
Version 3.1.0-dev
MMAP Support Enabled
MMAP File Mask /tmp/apc.vZ7gOa
Locking type File Locks
Revision $Revision: 3.184 $
Build Date Aug 31 2008 19:03:55

PowerPC G5 2 x 1.8 GHz   Mac OS X (10.5.4)    
Ron Smith2

Posts: 12
Registered: Oct 15, 2005
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Oct 24, 2008 9:56 PM   in response to: LarryJ
 

LarryJ wrote:

Here's the second 'gotcha':
Run the following configure command. Paste in the entire command. Be sure there are no line breaks in it:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure

When I do this part I get:

checking for egrep... grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for gcc... gcc
checking for C compiler default output file name... configure: error: C compiler cannot create executables
See `config.log' for more details.

I have the developer tools installed of course. I copied the files and followed your instructions exactly. Is the C compiler error simply a permissions issue do you think? I couldn't make a lot out of the config.log details.

Ron

G5 PPC   Mac OS X (10.5.5)   Server OS  
Ron Smith2

Posts: 12
Registered: Oct 15, 2005
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Oct 25, 2008 7:51 AM   in response to: Ron Smith2
 

SOLVED! This was a case of having upgraded from 10.4 OS X Server to 10.5 for the operating system but NOT the developer tools. I inserted the OS X Server install disk and in the Other Installs folder, I located the Xcode install tools file.

The install went cleanly and no restart was required. The ./configure command that failed before worked smoothly. Now on to the rest of the install.

     
Ron Smith2

Posts: 12
Registered: Oct 15, 2005
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Oct 25, 2008 8:15 AM   in response to: Ron Smith2
 

OK! We're cooking with gas here! THANKS for everything guys! The PHP is all installed as is the APC accelerator (it rocks!) too.

I'm running OS X Server 10.5.5 on dual 2.7 Ghz PPC server and am very, very pleased!

Thanks also to Mark Lyianage for his PHP build. I'm looking forward to php6 now!

     
ashorlivs

Posts: 29
Registered: Mar 5, 2006
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Dec 9, 2008 10:23 PM   in response to: LarryJ
 

Thanks a lot for the tutorial!!

     
shorts


Posts: 67
From: Melbourne, Australia
Registered: May 20, 2004
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Jan 25, 2009 1:35 AM   in response to: LarryJ
 

Very nice tutorial Larry. Bookmarking for future reference. Cheers.

Home: iMac 24" 2.8Ghz, 4Gb RAM Work: iMac 17" Core Duo   Mac OS X (10.5.2)    
RodriModri

Posts: 8
From: Australia
Registered: Nov 25, 2007
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: Apr 16, 2009 11:39 PM   in response to: LarryJ
 

This tutorial is pretty good. Thanks Larry. The install broke my MySQL link from PHP though.
I can't figure out why, since it was working before. I can log into MySQL through the terminal no problem and I have set a root password, but PHP just won't give me MySQL joy!

I noticed in phpinfo() that MYSQL_SOCKET says "/tmp/mysql.sock". I read around that it may, however, be looking for it in /var/mysql/mysql.sock, which I didn't have. So I created a symbolic link in /var/mysql/ to /tmp/mysql.sock, but still not no joy.

I then tried to change the line in /usr/local/php5/lib/php.ini that reads "mysql.default_socket = ' to read "mysql.default_socket = /tmp/mysql.sock" and restarted apache and mysql but got no joy from PHP.

I then set mysql.default_socket = /var/mysql/mysql.sock and restarted apache and mysql, but still no joy and phpinfo() still shows MYSQL_SOCKET as /tmp/mysql.sock, as if what I've just told it makes no sense to it! Grr.

I'm really stumped on what to do next, I've tried maybe 40 times to get this up and working. Any help would be much appreciated.

MacBook Pro   Mac OS X (10.5.1)    
mike.joseph

Posts: 3
From: Michigan USA
Registered: Nov 25, 2007
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard
Posted: May 21, 2009 8:44 AM   in response to: LarryJ
 

Awesome guide, thanks.

Install went perfectly on an older G4 Xserve.

2.2GHz macbook pro, 2x2.66 mac pro   Mac OS X (10.5.7)    
aaron devisser

Posts: 25
Registered: Oct 25, 2006
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopa
Posted: May 22, 2009 8:30 PM   in response to: LarryJ
 

WHOoOt
Excellent instructions mate !
Thank you heaps :) I've been trying to work out how to update my servers php for nearly 2 years now.... iyey iyey iyey.
thanks again.

Imac 1.8Ghz Intel 10.5.7 Server   Mac OS X (10.5.7)   Macbook, MacPro, Emac, Imac's, Ibooks, and Powerbooks  
kevin metcalf

Posts: 12
Registered: Apr 13, 2005
Re: Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard
Posted: Aug 6, 2009 9:45 AM   in response to: LarryJ
 

I don't know if it has to do with the machine I'm on (dual 3.0 ghz quad core xserve running 10.5.8 server), or the fact that Leopard is now at 10.5.8, but the above instructions didn't quite work right. A couple of changes to note:

1. The entry in /etc/apache2/sites/+entropy-php.conf already contains the line:
LoadModule php5_module /usr/local/php5/libphp5.so
It doesn't need to be added to the /etc/apache2/httpd.conf file - just comment out the LoadModule line that's there (if you've changed it; it ships commented out).
2. The configure line should be slightly different than the one you've got here. You'll want to add --with-php-config=/usr/local/php5/bin/php-config to the end. If you don't, you'll get the following error in /var/log/apache2/error_log...
PHP Warning: PHP Startup: apc: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090626\nThese options need to match\n in Unknown on line 0
... and php_info() won't show APC as loaded. If you've already been playing around with this, you may want to do a make clean first:
make clean; MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load" ./configure --with-php-config=/usr/local/php5/bin/php-config
Also, by providing the direct link to php-config, make install should place the resulting module in the correct location.

3. This isn't technically an error, and I think it's covered in an FAQ on your php page, but if one runs into a problem with apachectl not working, please note that using apachectl instead of httpd -t (which does the same thing) may result in the following error:

httpd: Syntax error on line 1455 of /private/etc/apache2/httpd.conf: Syntax error on line 8 of /etc/apache2/sites/+entropy-php.conf: Cannot load /usr/local/php5/libphp5.so into server: dlopen(/usr/local/php5/libphp5.so, 10): Symbol not found: _libiconv\n Referenced from: /usr/local/php5/lib/libintl.8.dylib\n Expected in: /usr/lib/libiconv.2.dylib\n

This isn't actually a show stopper! Apache will still run. Darn it. >.<

Anyway, that you SO much for this article. It was immensely helpful. I hope my additional notes here will help a tiny bit toward making this install smooth for whoever comes after.

  • Kevin


2x3 GHz Quad Core Intel Xeon Xserve   Mac OS X (10.5.8)    
MonkeyTrainer

Posts: 8
From: Dallas, TX
Registered: May 4, 2008
Built-in php5 with APC accelerator on Mac OS X 10.6 Snow Leopard
Posted: Aug 30, 2009 11:54 PM   in response to: kevin metcalf
 

Trying the same thing with Snow Leopard release and running into trouble.

First, I removed the references to the PPC architecture in the config statement, and targeted the PHP 5.3 php-config installation, leaving:

MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" ./configure --with-php-config=/usr/bin/php-config

This ran without error but upon make, the build ends with a few errors like this:
"In file included from /usr/bin/APC-3.1.3p1/APC-3.1.3p1/apc.c:43:
/usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory"

And a showstopper of:
"lipo: can't open input file: /var/folders/rK/rKmFKqV5E4yofTbQK1zc6++++TI/-Tmp-//ccTbewyQ.out (No such file or directory)"

Guesses?

MacBook Pro 15"   Mac OS X (10.6)    
Shane Depner1


Posts: 168
Registered: May 28, 2003
Re: Built-in php5 with APC accelerator on Mac OS X 10.6 Snow Leopard
Posted: Oct 23, 2009 5:07 PM   in response to: MonkeyTrainer
 

I was able to install APC on my 10.6 server. I am not using the Apple built-in PHP (not sure that makes a difference).

1. I installed dev tools
2. Downloaded APC and unzipped
3. cd /Desktop/APC-3.1.3p1
4. I /usr/local/php/bin/phpize (this fails if you don’t have dev tools as it relies on autoconf and pecl or pear, I forget)
4. ./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/local/php/bin/php-config
6. make
7. sudo make install
(I had to sudo, you may or may not have to depending on your setup).

This obviously requires perl and I may or may not have installed libs for other perl modules. If you’re missing a specific per module, it’ll tell you.

This placed the apc.so in my php extensions folder.

Note that in step 3 and 4 I specify /usr/local/php - this could be anything really, in my case it is php5-cgi but you use whatever you installed there. I can’t confirm that this works on entrophy php but I can confirm that it works just fine with a CGI build that I use. Quite the performance improvement on a drupal site we’re running I might add.