Computersnyou

how to upgrade php in mac OSX | compiling from source

Posted on  9/7/2012

Mac OSX  come with pre-installed php  , but many time you will find that its old version or you want to upgrade for your project specific needs then use this guide to download and install most up to date php in your mac OSX

<p>
  <b>Test your php installation&nbsp;</b><br />open terminal and type
</p>

<pre class="codesBash">php --version</pre>

<p>
  you will see something like this
</p>

<div class="separator" style="clear: both; text-align: center;">
  <a href="http://2.bp.blogspot.com/--ymSNy13Po0/UEoPsHxrHWI/AAAAAAAAGqM/SyiHs_J1aXg/s1600/php+--version.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="338" src="http://2.bp.blogspot.com/--ymSNy13Po0/UEoPsHxrHWI/AAAAAAAAGqM/SyiHs_J1aXg/s640/php+--version.png" width="640" /></a>
</div>

<p>
  <a name="more"></a>
</p>

<div style="text-align: center;">
</div>

<p>
  or if you will check with phpinfo&nbsp;function you will see your php installation info
</p>

<pre><?php&nbsp;phpinfo()&nbsp; ??></pre>

<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;">
  <tr>
    <td style="text-align: center;">
      <a href="http://3.bp.blogspot.com/-WimQ0BhNzRY/UEoP17d-F5I/AAAAAAAAGqU/dsPWw6SSTkY/s1600/phpinfo.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="517" src="http://3.bp.blogspot.com/-WimQ0BhNzRY/UEoP17d-F5I/AAAAAAAAGqU/dsPWw6SSTkY/s640/phpinfo.jpg" width="640" /></a>
    </td>
  </tr>
  
  <tr>
    <td class="tr-caption" style="text-align: center;">
      phpinfo&nbsp;
    </td>
  </tr>
</table>

<p>
  Tested on mac OSX snow leopard and mountain lion ( intel )
</p>

<p>
  <br class="Apple-interchange-newline" /><b>Prerequisite knowledge and software for compiling php :&nbsp;</b>
</p>

<ul>
  <li>
    Basic Unix skills (being able to operate &#8220;make&#8221; and a C compiler)
  </li>
  <li>
    An ANSI C compiler
  </li>
  <li>
    A web server
  </li>
  <li>
    Any module specific components (such as GD, PDF libs, etc.)
  </li>
</ul>

<p>
  <span style="color: #cc0000; font-size: large;">Install<b> XCODE</b> and <b>XCODE command lines tools</b> before start compiling</span>
</p>

<p>
</p>

<div style="text-align: center;">
  <a class="download-button" href="https://github.com/kennethreitz/osx-gcc-installer" target="_blank">Download&nbsp;</a>
</div>

<div style="text-align: center;">
  </p> 
  
  <div style="text-align: left;">
    Steps :&nbsp;
  </div>
  
  <div style="text-align: left;">
    1: &nbsp;Download PHP source codes&nbsp;
  </div>
  
  <div style="text-align: left;">
    2 : extract source code&nbsp;
  </div>
  
  <div style="text-align: left;">
    3 : open terminal and change directory to extracted folder&nbsp;
  </div>
  
  <div style="text-align: left;">
    4: complie with</p> 
    
    <div>
      <span style="background-color: white;"><br /></span></p> 
      
      <h3 style="text-align: left;">
        <span style="background-color: white;">install&nbsp;dependencies&nbsp;first&nbsp;</span>
      </h3>
      
      <p>
      </p>
      
      <div style="text-align: left;">
      </div>
      
      <ul style="text-align: left;">
        <li>
          brew install libjpeg
        </li>
        <li>
          brew install pcre
        </li>
        <li>
          brew install libxml2
        </li>
        <li>
          brew install mcrypt
        </li>
        <li>
          brew install openssl&nbsp;
        </li>
        <li>
          brew install libpng&nbsp;
        </li>
      </ul>
      
      <p>
        now&nbsp;customise&nbsp;and configure php installation according to your need
      </p>
    </div>
    
    <pre class="codesBash">./configure  <br />--prefix=/usr  <br />--mandir=/usr/share/man  <br />--infodir=/usr/share/info  <br />--sysconfdir=/private/etc  <br />--with-apxs2=/usr/sbin/apxs  <br />--enable-cli  <br />--with-config-file-path=/etc  <br />--with-libxml-dir=/usr  <br />--with-openssl=/usr  <br />--with-kerberos=/usr  <br />--with-zlib=/usr  <br />--enable-bcmath  <br />--with-bz2=/usr  <br />--enable-calendar  <br />--with-curl=/usr  <br />--enable-dba  <br />--enable-exif  <br />--enable-ftp  <br />--with-gd  <br />--enable-gd-native-ttf  <br />--with-icu-dir=/usr  <br />--with-iodbc=/usr  <br />--with-ldap=/usr  <br />--with-ldap-sasl=/usr  <br />--with-libedit=/usr  <br />--enable-mbstring  <br />--enable-mbregex  <br />--with-mysql=mysqlnd  <br />--with-mysqli=mysqlnd  <br />--without-pear  <br />--with-pdo-mysql=mysqlnd  <br />--with-mysql-sock=/var/mysql/mysql.sock  <br />--with-readline=/usr  <br />--enable-shmop  <br />--with-snmp=/usr  <br />--enable-soap  <br />--enable-sockets  <br />--enable-sysvmsg  <br />--enable-sysvsem  <br />--enable-sysvshm  <br />--with-tidy  <br />--enable-wddx  <br />--with-xmlrpc  <br />--with-iconv-dir=/usr  <br />--with-xsl=/usr  <br />--enable-zip  <br />--with-imap=/usr/local/imap-2007 <br />--with-kerberos <br />--with-imap-ssl <br />--enable-intl <br />--with-pcre-regex  <br />--with-pgsql=/usr  <br />--with-pdo-pgsql=/usr <br />--with-freetype-dir=/usr/X11 <br />--with-jpeg-dir=/usr  <br />--with-png-dir=/usr/X11</pre>
    
    <pre class="codesBash"><br /></pre>
    
    <p>
      Now test and install if all is good
    </p>
    
    <ul style="text-align: left;">
      <li>
        <span style="font-family: inherit;">make test&nbsp;</span>
      </li>
      <li>
        <span style="font-family: inherit;">sudo make install<br /></span>
      </li>
    </ul>
  </div>
</div>
<p>
  after installation again type
</p>

<pre class="codesBash">php --version</pre>

<div class="separator" style="clear: both; text-align: center;">
  <a href="http://2.bp.blogspot.com/-gX__4zx8G8s/UEoXFtygkWI/AAAAAAAAGrk/JcDN4wFrCEc/s1600/Screen+Shot+2012-09-07+at+9.08.55+PM.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="275" src="http://2.bp.blogspot.com/-gX__4zx8G8s/UEoXFtygkWI/AAAAAAAAGrk/JcDN4wFrCEc/s400/Screen+Shot+2012-09-07+at+9.08.55+PM.png" width="400" /></a>
</div>

<div class="separator" style="clear: both; text-align: center;">
</div>

<div style="background-color: rgba(138, 138, 138, 0.5);">
  &nbsp; if above method dont work for you use<br />&nbsp; <a href="http://php-osx.liip.ch/">http://php-osx.liip.ch/</a></p>
</div>

<p>
  Settting up php <a href="http://www.computersnyou.com/2012/06/setting-up-apache-and-php-with-mysql-in.html" target="_blank">mysql and apache on mac osx see this guide >>&nbsp;</a></div> 
  
  <div>
  </div></div>

  • Home
  • Home
  • Home
About
lorem lasda asda adasd adsad lorem lasda asda adasd adsad lorem lasda asda adasd adsad lorem lasda asda adasd adsad lorem lasda asda adasd adsad lorem lasda asda adasd adsad