Kim's Adventures into Geekspace - Tag - PostgresGiving back to the community my way.2024-03-17T15:02:08+01:00Kim Gammelgaardurn:md5:b92093bac985c77abe5a5153eefcd985DotclearPostgres.app, PHP and Yosemiteurn:md5:9e0cd761bbe6ba1ebabc19f9a3aae4da2014-10-18T08:25:00+02:002014-10-18T11:26:41+02:00Kim GammelgaardAppleMacPHPPostgrestroubleshooting <p>After upgrading to Mac OS X Yosemite, the connection to my Postgres-DB from PHP failed again. Funny that Apple puts Postgres on their OS X Server, but don’t compile PHP (on their normal edition) so you can use it.</p>
<p>The help was like last time:</p>
<p>Using this guide:</p>
<blockquote>
<p>http://coolestguidesontheplanet.com/upgrade-to-php-5-4-or-5-5-mac-osx-10-8-mountain-lion/</p>
</blockquote>
<p>I found this:</p>
<blockquote>
<p>curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4</p>
</blockquote>
<p>but decided to go for php 5.5 (I could probably have gone 5.6 by now, but I was at 5.5 before and I didn’t want to break a thing that just works), so I change it to :</p>
<blockquote>
<p>curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5</p>
</blockquote>
<p>And my site was up running again in less than 5 minutes!</p>
<p>There was a warning that 5.5.17 which I got, had not been tested with Yosemite, but it seems to work for me.<br /></p>Postgres.app, PHP and Mavericksurn:md5:674c32710a11024da5e6ba14e10fbd412013-10-22T17:21:00+02:002013-11-10T15:33:51+01:00Kim GammelgaardAppleMacPHPPostgrestroubleshooting <p>Update 10 November 2013: after updating Mavericks from GM to build 13A603, everything broke again. After recompiling like specified below nothing was working and there may have been a missing path somewhere in the php.ini-file. While tracking the error down, I stumbled over a new version of PHP with a one-line install on <a href="http://www.coolestguidesontheplanet.com." title="http://www.coolestguidesontheplanet.com.">http://www.coolestguidesontheplanet.com.</a> I decided on 5.5 while I was at it.:</p>
<p><a href="http://www.coolestguidesontheplanet.com/upgrade-to-php-5-4-or-5-5-mac-osx-10-8-mountain-lion/" title="easy PHP 5.5-installation">easy PHP 5.5-installation</a></p>
<p>Just running the installation command, a curl, the postgres-connection was working again, even from a non-standard postgres-installation. Thumbs up.</p>
<p>--</p>
<p>I updated a few of my computers to Mac OS X 10.9 Mavericks. Everything went fine, or so I thought until my wife complained about a missing blog. I happen to run this blog on <a href="http://dotclear.org" title="Dotclear website">Dotclear</a> using a <a href="http://postgresapp.com" title="PostgreSQL on Mac">Postgres.app</a>-database. Dotclear is of course using php and Apache.</p>
<p>Soon it was clear that the good folks at Apple have dropped support for Postgres in their php-configuration, so what to do. But I found this rather helpful page:</p>
<p><a href="http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks" title="http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks">http://blog.rupey.org/post/63221360055/adding-postgres-support-to-php-on-os-x-mavericks</a><br /></p>
<p>It was not perfect though, as a few steps were a bit shorthanded: installing autoconf from brew for instance, but that was fairly easy after a bit of googling, so I won’t repeat those steps here. See <a href="http://stackoverflow.com/questions/6588174/enabling-postgresql-support-in-php-on-mac-os-x" title="Stackoverflows description of almost the same including brew-installation">here</a>, if you like.</p>
<p>I think that Rupey gets it very right for the rest, that is if you have Postgres installed by hand, i.e. that it is comfortably sitting in /usr/local/pgsql/ or similar. Given that I had used the app-version - much simpler to install and run - I had to point the configuration to the right directory. So when doing this</p>
<blockquote>
<p>cd ext/pdo_pgsql</p>
<p>phpize</p>
<p>./configure</p>
</blockquote>
<p>I ended up with this error:</p>
<blockquote>
<p>checking for pg_config... not found</p>
<p>configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path</p>
</blockquote>
<p>To point out the right installation path I just had to do this:</p>
<blockquote>
<p>./configure --with-pdo-pgsql=/Applications/Postgres.app/Contents/MacOS/bin</p>
</blockquote>
<p>before doing the rest:</p>
<blockquote>
<p>make</p>
<p>sudo make install</p>
</blockquote>
<p>and finally adding extension=pdo_pgsql.so to /etc/php.ini (and changing the time zone) and doing a sudo httpd -k graceful to make php work with Postgres again. Sorry for the downtime, btw.</p>