Entropy php5 with GD support and APC accelerator on Mac OS X 10.5 Leopard
http://docs.moodle.org/en/Stepby_Step_Installation_on_a_Mac_OS_X_10.5Server
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 DEPLOYMENTTARGET=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 atload" ./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 fileshint=1024
apc.mmap filemask=/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)