Mohamed Hassan
Mohamed Hassan

Reputation: 1619

how do i install php 5.4 on Mac OS X Lion?

I have downloaded php 5.4.0 from php.net and i want to upgrade it on mac os X lion.

I also want to ask if anyone knows how to upgrade apache.

Thanks in advance.


hi i have installed it but i don't know how to configure it with httpd.conf

 /usr/local/bin/php -v
PHP 5.4.0 (cli) (built: Mar  3 2012 02:41:24) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

i tried to add this to httpd.conf

as it said but the web server doesn't want to start

LoadModule php5_module libexec/libphp5.so

Upvotes: 26

Views: 37026

Answers (6)

memoryleak
memoryleak

Reputation: 460

I've blogged about how to upgrade your local PHP installation to 5.4.

Archiving content incase of external site failure:

Now let’s upgrade PHP in a few steps:

1. Download and unpack the PHP source archive
2. Install following packages using brew: libjpeg and pcre
3. Change directory to the source archive of PHP
4. Use the configure command to prepare the compilation process:

./configure  \
--prefix=/usr  \
--mandir=/usr/share/man  \
--infodir=/usr/share/info  \
--sysconfdir=/private/etc  \
--with-apxs2=/usr/sbin/apxs  \
--enable-cli  \
--with-config-file-path=/etc  \
--with-libxml-dir=/usr  \
--with-openssl=/usr  \
--with-kerberos=/usr  \
--with-zlib=/usr  \
--enable-bcmath  \
--with-bz2=/usr  \
--enable-calendar  \
--with-curl=/usr  \
--enable-dba  \
--enable-exif  \
--enable-ftp  \
--with-gd  \
--enable-gd-native-ttf  \
--with-icu-dir=/usr  \
--with-iodbc=/usr  \
--with-ldap=/usr  \
--with-ldap-sasl=/usr  \
--with-libedit=/usr  \
--enable-mbstring  \
--enable-mbregex  \
--with-mysql=mysqlnd  \
--with-mysqli=mysqlnd  \
--without-pear  \
--with-pdo-mysql=mysqlnd  \
--with-mysql-sock=/var/mysql/mysql.sock  \
--with-readline=/usr  \
--enable-shmop  \
--with-snmp=/usr  \
--enable-soap  \
--enable-sockets  \
--enable-sysvmsg  \
--enable-sysvsem  \
--enable-sysvshm  \
--with-tidy  \
--enable-wddx  \
--with-xmlrpc  \
--with-iconv-dir=/usr  \
--with-xsl=/usr  \
--enable-zip  \
--with-pcre-regex  \
--with-pgsql=/usr  \
--with-pdo-pgsql=/usr \
--with-freetype-dir=/usr/X11 \
--with-jpeg-dir=/usr  \
--with-png-dir=/usr/X11     

That’s it. After successful configuration use ‘make test’ to check your compilation and ‘sudo make install’ to actually install the new version.

Upvotes: 24

Eric Herlitz
Eric Herlitz

Reputation: 26307

I would really like to recommend this solution http://php-osx.liip.ch/

Upvotes: 10

Chuan Ma
Chuan Ma

Reputation: 9914

With MacPorts,

  sudo port install php54 

The above will install php54 in /opt/local/bin/php54.

/etc] php54 -v
PHP 5.4.8 (cli) (built: Oct 19 2012 11:30:15) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

You may install other modules you like. For example, I use both memcache and apc a lot. Do the following:

  sudo port install php54-memcache php54-apc

For other php54 modules you may want to add, you can find them using:

  port search php54

I did the following to make it my default php

  sudo port select php php54

Upvotes: 20

cwd
cwd

Reputation: 54856

@memoryleak's blog post looks pretty good. However, I was looking for resources on how to install a LAMP stack on ML I found this guide from diymacserver which looks fairly extensive. A sample:

Here are the instructions for installing, configuring and starting your MAMP stack on you Intel Mac running Lion. Please note these instructions are not intended for the server version of the OS.

It covers the following things:

  • Installing MySQL
  • Securing your MySQL installation
  • Starting MySQL automatically
  • Installing Apache
  • Compiling Apache
  • Configuring Apache
  • Starting Apache automatically
  • Configuring virtual hosts with Apache
  • Configuring HTTPS with virtual hosts
  • Compiling PHP
  • Adding the GD module to PHP
  • Adding the mcrypt module to PHP
  • Latest tested versions
  • Upgrading MySQL

I'm excited about installing a 64 bit lamp stack on ML now.

Upvotes: 1

lll
lll

Reputation: 12889

Edit:

Don't do it like this any more. There is a php54 port available on MacPorts now.


So just for fun I gave it a go via Macports.

Macports is still on PHP 5.3.10, so I edited the Portfile.

$ cd /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/lang/php5
$ sudo vi Portfile

Changed:

version -> 5.4.0
autoconf213 -> autoconf
checksums -> rmd160 7842f4f2b0aa064e10c82b5702cb8333bcb97f24

After the changes I ran:

$ sudo port install php5
...
$ php -v
...
PHP 5.4.0 (cli) (built: Mar  2 2012 15:02:14) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies

It seems to have broken some of the module paths, but I'm sure its an easy fix.

Edit: Broken modules were fixed by going into their respective portfiles, changing the PHP version and the checksum, and reinstalling.

Upvotes: 14

Przemek
Przemek

Reputation: 1

In case if you are missing UTF-8 support in PCRE, double check if you have old 8.02 pcre lib files in your /usr/lib after you install PHP 5.4 as @memoryleak suggested. This tip would saved me few hours today.

Upvotes: -1

Related Questions