{"id":749,"date":"2015-07-12T16:38:20","date_gmt":"2015-07-12T20:38:20","guid":{"rendered":"http:\/\/tech.creed3.com\/?p=749"},"modified":"2015-07-12T16:38:20","modified_gmt":"2015-07-12T20:38:20","slug":"updating-php-on-mac-os-x-server-10-6-8","status":"publish","type":"post","link":"https:\/\/tech.creed3.com\/?p=749","title":{"rendered":"Updating PHP on Mac OS X Server 10.6.8"},"content":{"rendered":"<p><img decoding=\"async\" style=\"margin: 0 0 4px 4px;\" alt=\"\" src=\"images\/stories\/php-med-trans.png\" width=\"95\" align=\"right\" border=\"0\" \/>So about that Mac development server on my local network. &nbsp;It&#8217;s an old Mac, an Intel dual core xeon. &nbsp;It runs OS X Server 10.6.8 which hasn&#8217;t had an update from Apple in at least a year I&#8217;m guessing. &nbsp;Which of course means PHP hasn&#8217;t been updated which is not good for a development server.<!--more--><\/p>\n<p>Even when you&#8217;re running a current version of OS X Server chances are your version of PHP is dated since Apple doesn&#8217;t exactly make that a priority. &nbsp;So in order to have at least a somewhat updated version of PHP you&#8217;re going to have to take matters into your own hands. &nbsp;Most sites agree it&#8217;s best to avoid any attempt at updating the PHP version that ships with the server as there could be any number of problems in doing so. &nbsp;That leaves installing the latest in a clean and different location.<\/p>\n<p>You could head on over to <a href=\"http:\/\/php.net\" target=\"_blank\">php.net<\/a> and grab the latest and compile it yourself. &nbsp;While I&#8217;m comfy enough within the guts of the OS, I&#8217;m not crazy abut the idea of spending an entire day doing this. &nbsp;Or as these things can go, a few days.<\/p>\n<p>I&#8217;ve read where others opt to go the <a href=\"http:\/\/brew.sh\/\" target=\"_blank\">Homebrew<\/a> route, which had I already been down that path before I&#8217;d probably give it a shot. &nbsp;Homebrew looks very interesting, but I&#8217;m not ready to commit to figuring it out.<\/p>\n<p>Then I discovered there&#8217;s a <a href=\"http:\/\/php-osx.liip.ch\/\" target=\"_blank\">&#8220;One Line Installation&#8221; method<\/a> maintained by the good folks at liip.ch that is touted by many as the quickest and easiest way to upgrade PHP. &nbsp;Now you&#8217;re talkin&#8217;! &nbsp;Rather than copy and paste what they have on their site, just head on over to <a href=\"http:\/\/php-osx.liip.ch\/\" target=\"_blank\">php-osx.liip.ch<\/a> and check it out.<\/p>\n<p>The install was pretty quick, and it makes no attempt to write over the PHP packaged with OS X Server, making an &#8220;undo&#8221; pretty easy as well should something not go well. &nbsp;However, it&#8217;s not quite a one line install. &nbsp;Oh the PHP installation was smooth, but not all was well after that single line was executed in terminal. &nbsp;An immediate refresh of a WordPress site failed with nothing more that the message <i>Error establishing a database connection<\/i>. &nbsp;So back to the search engines I go to try and diagnose the problem.<\/p>\n<p>Cutting to the chase, here are the other steps I took to get things running again. &nbsp;All steps are done in terminal and you might try using pico to edit the files in question rather than vi.<\/p>\n<p>In the apache config file httpd.conf found in \/etc\/apache2\/ I added <\/p>\n<pre><code>LoadModule php5_module \/usr\/local\/php5\/libphp5.so<\/code><\/pre>\n<p>In the apache plist file org.apache.httpd.plist found in \/System\/Library\/LaunchDaemons\/ I added<\/p>\n<pre><code>&lt;key&gt;EnvironmentVariables&lt;\/key&gt;\r\n&lt;string&gt;\/usr\/local\/php5\/&lt;\/string&gt;<\/code><\/pre>\n<p>And then changed<\/p>\n<pre><code>&lt;key&gt;Disabled&lt;\/key&gt;\r\n&lt;true\/&gt;<\/code><\/pre>\n<p>to <i>false<\/i><br \/>\nI&#8217;m not totally convinced this was necessary but I found a site that seemed to think it was.<\/p>\n<p>Lastly, the php.ini supplied with the new install had the mysql socket locations empty, leaving PHP in the dark on knowing where to find MySQL. &nbsp;For this you&#8217;ll need to know your particular installation and what the path to the socket is. &nbsp;My server is still running the old version of MySQL that Apple shipped (I know, bad bad boy). &nbsp;So the path for that is <i>\/var\/mysql\/mysql.sock<\/i>. &nbsp;Go to \/usr\/local\/php5\/lib\/ and edit php.ini making the following lines look like this:<\/p>\n<pre><code>pdo_mysql.default_socket = \/var\/mysql\/mysql.sock\r\nmysql.default_socket = \/var\/mysql\/mysql.sock\r\nmysqli.default_socket = \/var\/mysql\/mysql.sock<\/code><\/pre>\n<p>If all went well you should be running again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So about that Mac development server on my local network. &nbsp;It&#8217;s an old Mac, an Intel dual core xeon. &nbsp;It runs OS X Server 10.6.8 which hasn&#8217;t had an update from Apple in at least a year I&#8217;m guessing. &nbsp;Which of course means PHP hasn&#8217;t been updated which is not good for a development server.<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,16,30],"tags":[44,42,43],"class_list":["post-749","post","type-post","status-publish","format-standard","hentry","category-mac","category-technology","category-web-development","tag-mysql","tag-os-x-server","tag-php"],"views":1886,"_links":{"self":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts\/749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=749"}],"version-history":[{"count":0,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=\/wp\/v2\/posts\/749\/revisions"}],"wp:attachment":[{"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.creed3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}