PHP5 on Mac OSX 10.4 Tiger
I decided to upgrade to PHP5 on my Powerbook. PHP4 is nice, but not as nice as PHP5.
Here is a quick rundown of what I did.
If fink is installed you may install these optional and very useful libraries
fink install mysql-client mysql14-dev # MySQL: connects to MySQL fink install postgresql80 postgresql80-dev # PgSQL: connects to Postgresql fink install gd2 # GD: used for image manipulation
Download and extract the PHP5 source. Start Terminal and switch to the php5 source directory.
./configure --with-apxs --with-config-file-path=/etc --sysconfdir=/private/etc --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-openssl=/usr --enable-soap --with-xsl
Add these optional extensions if you installed the corresponding fink package.
--with-mysqli=/sw/bin/mysql_config --with-mysql=/sw --with-pgsql=/sw --with-gd=/sw --with-jpeg --with-png --with-ttf --with-freetype-dir=/usr/X11R6
After the configure is done run:
make sudo make install
Enable mod_php5 in Apache: open /etc/httpd/httpd.conf in your text editor. Toward the very bottom of the file replace <IfModule mod_php4.c> with <IfModule mod_php5.c>
sudo apachectl graceful
Verify setup:
echo "<? phpinfo(); ?>"> /Library/WebServer/Documents/index.php open "http://localhost/"
Posted: May 24th, 2005.
Tags: Linux/BSD, Mac
Comments
Comment from fungus
Time July 18, 2006 at 5:13 pm
Yes PHP5 will run on Apache 1.3.3. If your php info page is still showing PHP4, Apache is loading the wrong module. There are 3 lines that reference the module.
Here is what they look like:
LoadModule php4_module libexec/httpd/libphp4.so
...
AddModule mod_php4.c
...
<IfModule mod_php4.c>
My directions above assumed that the first two lines were modified by the “make install”. If that didn’t happen you have to change them yourself.
Just open the config file in your editor and search for php4 and replace with php5. Or for a quick one line command to make all the changes run this.
sed -i .bak -e 's/php4/php5/g' /etc/httpd/httpd.conf
Comment from Mark Bayhylle
Time July 18, 2006 at 2:45 pm
Hi there,
I need some help bad. I’ve tried the entropy package for php5.1.4 and I’ve also compiled from source using your instructions (which work great by the way). I still cannot get .php files to show in my browser and when I test the php config it still shows php4.x.x.
I’m on 10.4.7 with apache 1.3.3. This is killing me. Does php5 not work with apache1.3.3?
Thanks for any help you can provide.
Mark Bayhylle