<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>El Paso, TX, iPad and iPhone Development, Android Development, and Mobile Web Design and Development &#187; mysqli</title>
	<atom:link href="http://phidevinc.com/tag/mysqli/feed" rel="self" type="application/rss+xml" />
	<link>http://phidevinc.com</link>
	<description>iPhone App Development and Mobile Web Design and Development Experts</description>
	<lastBuildDate>Wed, 18 Apr 2012 15:29:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Recompiling PHP5 on Snow Leopard with MySQLi support, and other things</title>
		<link>http://phidevinc.com/recompiling-php5-in-snow-leopard-with-mysqli-support-and-other-things/tech-tips</link>
		<comments>http://phidevinc.com/recompiling-php5-in-snow-leopard-with-mysqli-support-and-other-things/tech-tips#comments</comments>
		<pubDate>Mon, 15 Mar 2010 04:51:54 +0000</pubDate>
		<dc:creator>Ares</dc:creator>
				<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[compiling]]></category>
		<category><![CDATA[mysqli]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://www.phidevinc.com/?p=446</guid>
		<description><![CDATA[[update 04.05.2010. If you got the OS X 10.6.3 update you may find yourself reading this again since it overwrites your php library. Yes, we found out the hard way. Backup your library first. ] We just got a new &#8230; <a href="http://phidevinc.com/recompiling-php5-in-snow-leopard-with-mysqli-support-and-other-things/tech-tips">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><span style="color: #aa0000;">[<strong>update 04.05.2010.</strong> If you got the OS X 10.6.3 update you may find yourself reading this again since it overwrites your php library. Yes, we found out the hard way. Backup your library first. ]</span></p>
<p>We just got a new workstation in the office. After getting it out of the box we were happy to realize that it already comes with a much better configuration for php 5.3 than the old 5.2 of OS X Leopard. Leopard only came with a very few and basic configuration and libraries, that were only fit to new web designer. Apparently they noticed this at Apple and this new version comes with a much better library set.<span id="more-446"></span></p>
<p>In general we have more than once person developing a site. So we use mysql databases that are hosted in a server that anyone can access, that way when someone makes a change to the databases it is immediately propagated to all developers, since we use something similar to a &#8220;networked drive.&#8221;</p>
<p>However, MySQL is still not included, but the folks at mysql have created a dmg that allows you to easily install mysql into your computer. You just need to download it, double click, and follow the prompt. The problem is that php comes with a strange version of mysqli. We were all exited and ready to go when:</p>
<p>Warning: mysqli::mysqli() [mysqli.mysqli] OK packet 6 bytes shorter than expected in /path/to/file on line&#8230;</p>
<div id="attachment_462" class="wp-caption alignright" style="width: 310px"><a href="http://www.phidevinc.com/media/2010/03/Screen-shot-2010-02-23-at-1.20.27-PM.png" rel="images"><img class="size-medium wp-image-462  " title="mysqlidev?" src="http://www.phidevinc.com/media/2010/03/Screen-shot-2010-02-23-at-1.20.27-PM-300x154.png" alt="" width="300" height="154" /></a><p class="wp-caption-text">mysqlidev won&#39;t let you connect to remote servers</p></div>
<p>This happens because the mysqli API library that php is using is the one that comes by default, not the one from the mysql version we just installed. Shoots, we need to recompile, and since we are at it, we will also recomplile with the new version of jpeglib.</p>
<p>Now it makes sense just to grab the configure options shown by phpinfo, but for some reason it references some locations that do not exists for jpeglib and libpng. So we will need to compile those too. Also make sure to remove your dir path from pcre otherwise it will also trow you and error.</p>
<p>Okay, let&#8217;s do this. First we download our source for <a href="http://www.php.net">PHP</a>, <a href="http://www.ijg.org/">LibJPEG</a>, <a href="http://www.libpng.org/pub/png/libpng.html">LibPNG</a></p>
<p>Lets compile libjpeg first: Once you have uncompressed the source, just go into the directory and type in the following</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">MACOSX_DEPLOYMENT_TARGET</span>=<span style="color: #000000;">10.6</span>
&nbsp;
<span style="color: #007800;">CFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> <span style="color: #007800;">CXXFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> <span style="color: #007800;">LDFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-shared</span></pre></div></div>

<p>That should finish without problems, now go to your libpng folder and type the following</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--enable-shared</span></pre></div></div>

<p>Again, it should finish without problems. Do the same for libPNG, and</p>
<p>Now, it would make sense to compile php now, but there are some know bugs in php when compiling on a mac so lets get those corrected first, before we continue.</p>
<p>Fist you will need to modify the file <strong>ext/gd/libgd/gd_png.c</strong>, so open it with your favorite text editor and look for the following string:<br />
<code><br />
</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>png_check_sig <span style="color: #009900;">&#40;</span>sig<span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #808080; font-style: italic;">/* bad signature */</span></pre></div></div>

<p>&nbsp;</p>
<p>and replace it for this other line:<br />
<code><br />
</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>png_sig_cmp <span style="color: #009900;">&#40;</span>sig<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #808080; font-style: italic;">/* bad signature */</span></pre></div></div>

<p>&nbsp;</p>
<p>Now, using your favorite text editor go to the following file within your php source code <strong>ext/libiconv/libiconv.c</strong><br />
and look for<br />
<code><br />
</code></p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#ifdef HAVE_LIBICONV</span>
<span style="color: #339933;">#define iconv libiconv</span>
<span style="color: #339933;">#endif</span></pre></div></div>

<p>&nbsp;</p>
<p>and replace the libconv of the second line for just iconv</p>
<p>Okay, now we are ready to compile php, so go to the the root of your php source code and type in (copy &amp; paste) the following</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">CGLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> <span style="color: #007800;">CXXFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> <span style="color: #007800;">LDFLAGS</span>=<span style="color: #ff0000;">&quot;-arch x86_64 -Os -pipe -m64&quot;</span> .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #ff0000;">'--prefix=/usr'</span> <span style="color: #ff0000;">'--mandir=/usr/share/man'</span> <span style="color: #ff0000;">'--infodir=/usr/share/info'</span> <span style="color: #ff0000;">'--disable-dependency-tracking'</span> <span style="color: #ff0000;">'--sysconfdir=/private/etc'</span> <span style="color: #ff0000;">'--with-apxs2=/usr/sbin/apxs'</span> <span style="color: #ff0000;">'--enable-cli'</span> <span style="color: #ff0000;">'--with-config-file-path=/etc'</span> <span style="color: #ff0000;">'--with-libxml-dir=/usr'</span> <span style="color: #ff0000;">'--with-openssl=/usr'</span> <span style="color: #ff0000;">'--with-kerberos=/usr'</span> <span style="color: #ff0000;">'--with-zlib=/usr'</span> <span style="color: #ff0000;">'--enable-bcmath'</span> <span style="color: #ff0000;">'--with-bz2=/usr'</span> <span style="color: #ff0000;">'--enable-calendar'</span> <span style="color: #ff0000;">'--with-curl=/usr'</span> <span style="color: #ff0000;">'--enable-exif'</span> <span style="color: #ff0000;">'--enable-ftp'</span> <span style="color: #ff0000;">'--with-gd'</span> <span style="color: #ff0000;">'--with-jpeg-dir=/user/local'</span> <span style="color: #ff0000;">'--with-png-dir=/usr/local'</span> <span style="color: #ff0000;">'--enable-gd-native-ttf'</span> <span style="color: #ff0000;">'--with-ldap=/usr'</span> <span style="color: #ff0000;">'--with-ldap-sasl=/usr'</span> <span style="color: #ff0000;">'--enable-mbstring'</span> <span style="color: #ff0000;">'--enable-mbregex'</span> <span style="color: #ff0000;">'--with-mysql=mysqlnd'</span> <span style="color: #ff0000;">'--with-mysqli=/usr/local/mysql/bin/mysql_config'</span> <span style="color: #ff0000;">'--with-pdo-mysql=mysqlnd'</span> <span style="color: #ff0000;">'--with-mysql-sock=/var/mysql/mysql.sock'</span> <span style="color: #ff0000;">'--with-iodbc=/usr'</span> <span style="color: #ff0000;">'--enable-shmop'</span> <span style="color: #ff0000;">'--with-snmp=/usr'</span> <span style="color: #ff0000;">'--enable-soap'</span> <span style="color: #ff0000;">'--enable-sockets'</span> <span style="color: #ff0000;">'--enable-sysvmsg'</span> <span style="color: #ff0000;">'--enable-sysvsem'</span> <span style="color: #ff0000;">'--enable-sysvshm'</span> <span style="color: #ff0000;">'--with-xmlrpc'</span> <span style="color: #ff0000;">'--with-iconv-dir=/usr'</span> <span style="color: #ff0000;">'--with-xsl=/usr'</span> <span style="color: #ff0000;">'--with-pcre-regex'</span></pre></div></div>

<div id="attachment_467" class="wp-caption alignright" style="width: 310px"><a href="http://www.phidevinc.com/media/2010/03/mysqli-too-short-solved.png" rel="images"><img class="size-medium wp-image-467 " title="mysqli-too-short-solved" src="http://www.phidevinc.com/media/2010/03/mysqli-too-short-solved-300x102.png" alt="" width="300" height="102" /></a><p class="wp-caption-text">Life is good</p></div>
<p>Now, go and grab yourself a cup of coffee, this is going to take a while. After that you should be able to connect to any remote mysql server that you have access to.</p>
<p>If you share your workstation with someone else, then it may be a good idea to <a href="http://dev.mysql.com/doc/refman/5.1/en/default-privileges.html">secure your mysql installation</a>.</p>
<p>Now, in order to make your .htaccess files to work, you need to change your apache user settings. For that you need to go to /etc/apache2/users/USERNAME.conf and make sure it reads something like this<br />
Options Indexes -MultiViews FollowSymLinks<br />
AllowOverride All<br />
Order allow,deny<br />
Allow from all</p>
<p>You will also need to change the second AllowOverride that you find in your /etc/apache2/httpd.conf</p>
<p>Well, that should do it. So good luck and let us know if you run into any problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://phidevinc.com/recompiling-php5-in-snow-leopard-with-mysqli-support-and-other-things/tech-tips/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

