<?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>Kempwire.com &#187; PHP</title>
	<atom:link href="http://kempwire.com/archive/php/feed" rel="self" type="application/rss+xml" />
	<link>http://kempwire.com</link>
	<description>By Jonathan Kemp</description>
	<lastBuildDate>Thu, 20 May 2010 01:33:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Apache, PHP and MySQL on Snow Leopard</title>
		<link>http://kempwire.com/php/apache-php-and-mysql-on-snow-leopard.html</link>
		<comments>http://kempwire.com/php/apache-php-and-mysql-on-snow-leopard.html#comments</comments>
		<pubDate>Sat, 08 May 2010 02:21:10 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kempwire.com/?p=355</guid>
		<description><![CDATA[I have enjoyed using MacPorts for a number of reasons, and I have written about it several times. Recently, I have had to rely on it more, and I have grown frustrated with it to the point that I had to abandon it altogether. I upgraded to Snow Leopard (10.6) last week. It broke my [...]]]></description>
			<content:encoded><![CDATA[<p>I have enjoyed using MacPorts for a number of reasons, and I have written about it <a href="http://kempwire.com/php/install-apache-php-and-mysql-on-leopard-with-macports.html">several</a> <a href="http://kempwire.com/mac-os-x/install-apache-and-php-on-leopard-with-macports.html">times</a>. Recently, I have had to rely on it more, and I have grown frustrated with it to the point that I had to abandon it altogether.</p>
<p>I upgraded to Snow Leopard (10.6) last week. It broke my install of MacPorts, but they actually tell you to reinstall after an OS upgrade like this. So I did that, but I could not get Apache 2 and PHP running again to save my life, not to mention MySQL.</p>
<p>So I instead relied on the factory installs of Apache and PHP. It turns out they have gotten a lot better with Snow Leopard. All I had to do was reinstall MySQL which meant I lost my databases but I was prepared for that to happen by then anyway.</p>
<p>Here are the instructions to get Apache, PHP and MySQL running in Snow Leopard.</p>
<p><a href="http://maestric.com/doc/mac/apache_php_mysql_snow_leopard">Install Apache/PHP/MySQL on Snow Leopard</a></p>
<p>It worked perfectly for me except for one thing. PHP short tags are off by default. So make sure to turn them on or check your code to make sure you are not using PHP short tags, or your PHP code will not work.</p>
<p>I may continue to use MacPorts for other things, but for now I am no longer using it for my dev environment. Maybe one day I will give it another shot if I need it.</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=355&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/php/apache-php-and-mysql-on-snow-leopard.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Apache, PHP and MySQL on Leopard with MacPorts</title>
		<link>http://kempwire.com/php/install-apache-php-and-mysql-on-leopard-with-macports.html</link>
		<comments>http://kempwire.com/php/install-apache-php-and-mysql-on-leopard-with-macports.html#comments</comments>
		<pubDate>Tue, 23 Mar 2010 03:11:20 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kempwire.com/?p=337</guid>
		<description><![CDATA[Running selfupdate on MacPorts is a good way to keep your MacPorts software up to date. The problem is when I did this, all my settings were overwritten. I should also mention that running selfupdate on my MacPorts install caused all my virtual hosts to get overwritten as well. I wrote a post last year [...]]]></description>
			<content:encoded><![CDATA[<p>Running <code>selfupdate</code> on MacPorts is a good way to keep your MacPorts software up to date. The problem is when I did this, all my settings were overwritten. I should also mention that running <code>selfupdate</code> on my MacPorts install caused all my virtual hosts to get overwritten as well. I wrote a post last year on how to install Apache and PHP on Mac OS 10.5  with MacPorts, but following that post didn&#8217;t help me get up and running again. So I  figured I would write a new one that would actually have the right information.</p>
<p>Here are the install instructions you need for <a href="http://trac.macports.org/wiki/howto/MAMP">installing Apache, PHP and MySQL with MacPorts</a>. I had already installed Apache and PHP, but MySQL wasn&#8217;t working. I have MySQL server already installed and running, but PHP wasn&#8217;t finding it. I already had multiple databases set up, so I did not want to reinstall MySQL. All I had to do was follow the instructions in step 4. It fixed the problem, but there were a couple of settings that needed to be changed first.</p>
<p>After you install PHP, it gives you a 2 part message. Part 1,</p>
<p><code>Your php.ini contains a line that will prevent php5-mysql<br />
and other PHP extensions from working. To fix this,<br />
edit /opt/local/etc/php5/php.ini and delete this line:</code></p>
<p><code>extension_dir = "./"</code></p>
<p>is correct. Deleting that line is how you find the right extensions. Part 2,</p>
<p><code>To use mysqlnd with a local MySQL server, edit /opt/local/etc/php5/php.ini and set<br />
mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket<br />
to /opt/local/var/run/mysql5/mysqld.sock</code></p>
<p>did not work for me. For my MySQL server, that socket does not work. Instead, I found <a href="http://devdaily.com/blog/post/mac-os-x/problems-with-php-mysql-mac-os-x-kohana">this article</a> that tells you the correct socket on Leopard to set:</p>
<p><code>mysql.default_socket = /private/tmp/mysql.sock</code></p>
<p>That fixed everything for me, except for my virtual hosts. Again, your mileage may very. These instructions worked for me on my machine with the software I have.</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=337&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/php/install-apache-php-and-mysql-on-leopard-with-macports.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Create a Google Analytics Plugin for bbPress</title>
		<link>http://kempwire.com/php/how-to-create-a-google-analytics-plugin-for-bbpress.html</link>
		<comments>http://kempwire.com/php/how-to-create-a-google-analytics-plugin-for-bbpress.html#comments</comments>
		<pubDate>Tue, 14 Jul 2009 02:05:12 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kempwire.com/?p=309</guid>
		<description><![CDATA[bbPress is a free, open source forum software from the makers of WordPress. I am even using it on this site. It just came out of beta with the relase of 1.0. If you are looking for forum software I recommend it. However, the theming system is not as simple as WordPress. I had added [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://bbpress.org/">bbPress</a> is a free, open source forum software from the makers of WordPress. I am even <a href="http://kempwire.com/bb/">using it on this site</a>. It just came out of beta with the relase of 1.0. If you are looking for forum software I recommend it.</p>
<p>However, the theming system is not as simple as WordPress. I had added a Google Analytics script to my themes. But when I upgraded to 1.0, I lost all my tracking scripts.</p>
<p>The best way around this, I thought, is to create an analytics plugin. It turns out, it is very easy, especially if you have experience creating plugins with WordPress. The bbPress footer template has a hook for adding code to the footer. You just have to create the code that will add your tracking script to the footer of every page. That is it.</p>
<p>Here is an example of the code you can use. Download <a href="http://kempwire.com/wp-content/uploads/2009/07/bbpress-analytics.zip">bbpress-analytics</a> here. Just upload the script to your bb-plugins directory, and activate the plugin in the plugin admin. If you are using Google Analytics, all you need to do is replace &#8220;UA-XXXXXX-X&#8221; with your site code. But it will work with any tracking script, just replace the Google script with your own. Also you can use this same code to add any code you wanted to the footer.</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=309&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/php/how-to-create-a-google-analytics-plugin-for-bbpress.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing PHP 5 on Mac OS X</title>
		<link>http://kempwire.com/php/installing-php-5-on-mac-os-x.html</link>
		<comments>http://kempwire.com/php/installing-php-5-on-mac-os-x.html#comments</comments>
		<pubDate>Fri, 02 Nov 2007 23:04:24 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://kempwire.com/php/installing-php-5-on-mac-os-x.html</guid>
		<description><![CDATA[Okay, so I have been running PHP 4 locally on my Mac OS 10.4, but I recently needed to upgrade to PHP 5. In addition, PHP 4 will no longer be supported after the end of this year. The installation instructions are the same as for PHP 4, which is not a big deal. I [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so I have been running PHP 4 locally on my Mac OS 10.4, but I recently needed to upgrade to PHP 5. In addition, PHP 4 will no longer be supported after the end of this year. The installation instructions are the same as for PHP 4, which is not a big deal. I also installed libcurl, which is not included by default for some reason.</p>
<p>Why am I posting this here then? So I can reference it, whenever I need to recompile PHP again. I am installing new libs all the time, it seems like, so it helps to know what I have done each time so I can do it again the next time. This is the third or fourth time I have done this, so I won&#8217;t go into that much detail. If you need more details, look at my other posts.</p>
<p>For step one, download and unzip PHP 5. Then, open the folder and run configure, make and sudo make intall, like this.</p>
<p><code>./configure --prefix=/usr/local/apache2/php \<br />
--with-curl=/usr/local/src/curl-7.17.1 \<br />
--with-zlib-dir=/usr/local/lib \<br />
--with-jpeg-dir=/usr/local/lib \<br />
--with-png-dir=/usr/local/lib \<br />
--with-gd --with-mysql=/usr/local/mysql \<br />
--with-apxs2=/usr/local/apache2/bin/apxs<br />
make<br />
sudo make install</code></p>
<p>Remember to change your file paths, if they are different than mine. Restart Apache, and you&#8217;re done!</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=133&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/php/installing-php-5-on-mac-os-x.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Apache 2.0, PHP and Subversion on Mac OS 10.4</title>
		<link>http://kempwire.com/tips/installing-apache-20-php-and-subversion-on-mac-os-104.html</link>
		<comments>http://kempwire.com/tips/installing-apache-20-php-and-subversion-on-mac-os-104.html#comments</comments>
		<pubDate>Tue, 23 Oct 2007 11:42:02 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://kempwire.com/tips/installing-apache-20-php-and-subversion-on-mac-os-104.html</guid>
		<description><![CDATA[After trying to install Django on my Mac and failing, I have decided to try and upgrade my local version of Apache 1.3 to version 2.0. If you are developing on the Mac OS, you may know that Mac OS 10.4 comes with Apache installed on it. While this is one of the great things [...]]]></description>
			<content:encoded><![CDATA[<p>After <a href="http://kempwire.com/mac-os-x/i-cant-get-mod_python-and-django-working-on-my-mac.html">trying to install Django on my Mac and failing</a>, I have decided to try and upgrade my local version of Apache 1.3 to version 2.0. If you are developing on the Mac OS, you may know that Mac OS 10.4 comes with Apache installed on it. While this is one of the great things about the Mac OS, what&#8217;s not great is that it is out of date. For most cases when you are developing locally on the Mac, Apache 1.3 is fine. But, you may find that with Apache 1.3 installed, <a href="http://kempwire.com/mac-os-x/i-cant-get-mod_python-and-django-working-on-my-mac.html">you will not be able to run certain software</a>.</p>
<p>The solution to this is to upgrade to Apache 2.0. I admit that I was reluctant to do this myself, but I found a <a href="http://developer.apple.com/tools/subversionxcode.html">tutorial from Apple</a> that convinced me to try it. Apache 2.0.61 is the current stable version of the 2.0 series, and that is the version I decided to go with. I downloaded the package and extracted it into /usr/local/src using the following commands.</p>
<p><code>curl -O http://www.eng.lsu.edu/mirrors/apache/httpd/httpd-2.0.61.tar.gz<br />
tar xvfz httpd-2.0.61.tar.gz<br />
cd httpd-2.0.61<br />
export ac_cv_func_poll=no</code></p>
<p>Make the following changes to srclib/apr/network_io/unix/sendrecv.c in the apr_socket_send function:</p>
<p><strong>Change:</strong></p>
<p><code>do {<br />
rv = write(sock-&gt;socketdes, buf, (*len));<br />
} while (rv == -1 &amp;&amp; errno == EINTR);</code></p>
<p><strong>To:</strong></p>
<p><code>try_write: do {<br />
rv = write(sock-&gt;socketdes, buf, (*len));<br />
} while (rv == -1 &amp;&amp; errno == EINTR);</code></p>
<p>(That is, add &#8220;try_write:&#8221; right before the &#8220;do {&#8220;.)</p>
<p>Replace the following else clause (that is, delete these five lines):</p>
<p><code>else {<br />
do {<br />
rv = write(sock-&gt;socketdes, buf, (*len));<br />
} while (rv == -1 &amp;&amp; errno == EINTR);<br />
}</code></p>
<p>with these two lines:</p>
<p><code>else<br />
goto try_write;</code></p>
<p>Run configure, run make, and then run sudo make install to set up Apache 2.0 for installation:</p>
<p><code>./configure --enable-mods-shared=most --enable-ssl \<br />
--with-mpm=worker --without-berkeley-db<br />
make<br />
sudo make install</code></p>
<p>Create a directory for mod_dav.h, and copy the module to it using the following Terminal commands:</p>
<p><code>cd /usr/local/apache2<br />
mkdir -p modules/dav/main<br />
cp include/mod_dav.h modules/dav/main/</code></p>
<p>Once you have it installed,  run the following command to start Apache.</p>
<p><code>sudo /usr/local/apache2/bin/apachectl start</code></p>
<p>You also need to run the following commands to start Apache 2.0 on each reboot.<br />
<code><br />
sudo -s<br />
mkdir /Library/StartupItems   # This directory might already exist<br />
ditto /System/Library/StartupItems/Apache /Library/StartupItems/Apache2<br />
mv /Library/StartupItems/Apache2/Apache /Library/StartupItems/Apache2/Apache2<br />
defaults write /Library/StartupItems/Apache2/StartupParameters Provides -array "Apache2"<br />
perl -p -i -e 's/WEBSERVER/APACHE2/g' /Library/StartupItems/Apache2/Apache2<br />
echo "APACHE2=-YES-" &gt;&gt; /etc/hostconfig<br />
</code></p>
<p>I have a problem now in that turning off and on web sharing in the system preferences will not stop and start Apache 2.0. I am at a loss on how to make this work. I am also unsure whether or not Apache 2.0 will start on reboot or whether I have to start it manually.</p>
<p>Subversion is rather easy to install. I used the <a href="http://hivelogic.com/narrative/articles/svn_on_os_x">tutorial found at hivelogic</a> along with the same one I <a href="http://developer.apple.com/tools/subversionxcode.html">used to install Apache 2.0</a>. Subversion appears to be installed and working but I haven&#8217;t really tested it in depth.</p>
<p>Once I had Apache 2.0 installed, I wanted to be able to access it when I go to http://localhost/ and access the files in /Library/Webserver/Documents. You need to stop Apache and then edit the http.conf file found in /usr/local/apache2/conf/httpd.conf. Then you need to change the DocumentRoot and the Directory.</p>
<p><code>DocumentRoot "/Library/Webserver/Documents"<br />
&lt;Directory "/Library/Webserver/Documents"&gt;</code></p>
<p>Now you can restart Apache and you should be able to access Apache 2.0 on http://localhost/. However, I found that PHP was no longer working because I had not yet installed it for Apache 2.0. Don&#8217;t worry though all you have to do is recompile it. Here are the steps I used.</p>
<p>If you already have the php files on your machine, go into that directory.</p>
<p><code>cd /usr/local/src/php-4.4.7</code></p>
<p>If not download it and unpack it again and then go into the directory you just created. Now you need to create the directory to install PHP into.</p>
<p><code>sudo mkdir /apache2/php</code></p>
<p>Then all you need to do is configure it with the right options. I used the following commands which adds support for the GD graphics library, in addition to mysql.</p>
<p><code>./configure --prefix=/usr/local/apache2/php \<br />
--with-zlib-dir=/usr/local/lib \<br />
--with-jpeg-dir=/usr/local/lib \<br />
--with-png-dir=/usr/local/lib \<br />
--with-gd --with-mysql=/usr/local/mysql \<br />
--with-apxs2=/usr/local/apache2/bin/apxs<br />
make<br />
sudo make install</code></p>
<p>I ran into problems doing this. I kept getting the error from mysql.</p>
<p><code>dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib</code></p>
<p>I fixed this by copying the file into that path using the following commands.<br />
<code><br />
cd /usr/local/mysql/lib<br />
mkdir mysql<br />
cp libmysqlclient.15.dylib mysql/libmysqlclient.15.dylib</code></p>
<p>I ran configure, make, sudo make install again, and it worked. An optional step you may want to take is to create a php.ini file. I created the php.ini file with this command.<br />
<code><br />
sudo cp php.ini-dist /apache2/php/lib/php.ini</code></p>
<p>Now we need to edit the http.conf again so that PHP will run in Apache. Add the following lines in the appropriate sections.</p>
<p><code>LoadModule php4_module modules/libphp4.so<br />
DirectoryIndex index.html index.php<br />
AddType application/x-httpd-php .php</code></p>
<p>Now restart Apache 2.0. Once I did that it worked. I now have Apache 2.0, PHP 4.4.7 and Subversion 1.3 installed locally on my Mac.</p>
<p><strong>Disclaimer:</strong> Your mileage may vary. This is the compilation of a lot of work over a period of several days. I have tried to recount the steps I used as closely as possible. Use at your own risk. Here are some tutorials you may want to look at if you get stuck. Good luck.</p>
<p><a href="http://www.phpmac.com/articles.php?view=252">Building and Installing Apache 2.2.4 and PHP 5.1.4 on Mac OS X 10.4.6</a><br />
<a href="http://www.php.net/manual/en/install.unix.apache2.php">Apache 2.0 on Unix systems</a></p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=124&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/tips/installing-apache-20-php-and-subversion-on-mac-os-104.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Restart Apache Locally on Mac OS X</title>
		<link>http://kempwire.com/tips/how-to-restart-apache-locally-on-mac-os-x.html</link>
		<comments>http://kempwire.com/tips/how-to-restart-apache-locally-on-mac-os-x.html#comments</comments>
		<pubDate>Sat, 06 Oct 2007 20:23:45 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://kempwire.com/tips/how-to-restart-apache-locally-on-mac-os-x.html</guid>
		<description><![CDATA[Working with PHP and Apache locally on my Mac, I found myself needing to know how to restart Apache. The method I normally use did not work because for some reason etc/init.d does not exist or could not be found. So I found another command that worked. Simply run the following. sudo apachectl graceful graceful [...]]]></description>
			<content:encoded><![CDATA[<p>Working with PHP and Apache locally on my Mac, I found myself needing to know how to restart Apache. The method I normally use did not work because for some reason <code>etc/init.d</code> does not exist or could not be found. So I found another command that worked. Simply run the following.</p>
<p><code>sudo apachectl graceful</code></p>
<p><code>graceful</code> reloads the configuration files and gracefully restarts. Any current connections are allowed to complete. That&#8217;s it! You just restarted Apache. Easy huh?</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=111&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/tips/how-to-restart-apache-locally-on-mac-os-x.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing GD Graphics Library on Mac OS X</title>
		<link>http://kempwire.com/tips/installing-gd-graphics-library-on-mac-os-x.html</link>
		<comments>http://kempwire.com/tips/installing-gd-graphics-library-on-mac-os-x.html#comments</comments>
		<pubDate>Sat, 06 Oct 2007 02:55:54 +0000</pubDate>
		<dc:creator>Jonathan Kemp</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://kempwire.com/tips/installing-gd-graphics-library-on-mac-os-x.html</guid>
		<description><![CDATA[Recently, I needed to install the GD Graphics Library locally on my Mac. GD is an open source code library for the dynamic creation of images by programmers. GD creates PNG, JPEG and GIF images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I needed to install the <a href="http://www.libgd.org/Main_Page">GD Graphics Library</a> locally on my Mac. GD is an open source code library for the dynamic creation of images by programmers. GD creates PNG, JPEG and GIF images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use on the web, the most common applications of GD involve web site development.</p>
<p>I searched through a lot of tutorials, and found that most of them are out of date and/or incomplete. In spite of this, I finally managed to figure it out. However, I took notes on everything I did so that someone else needing to do this will find this helpful and won&#8217;t have to struggle with it as much as I did.</p>
<p>I have to admit I am pretty green when it comes to using command line and installing open source code  on my computer. I have learned a lot though and I really enjoy it. I have found that the Mac is a great open source programming environment. Many programmers are figuring this out, and I believe you will continue to see more programmers coming to the Mac platform.</p>
<p>Anyway, these instructions, as straightforward as they are, still assume you know the basics of how to install and run open source code on your computer. If you don&#8217;t, you need to go read more and then come back here. Now, let&#8217;s begin.</p>
<p>The first thing you need to do is download the packages you will need. Here is the commands you will use for the most current versions of these packages as of this posting.</p>
<p><code>curl -O http://www.zlib.net/zlib-1.2.3.tar.gz<br />
curl -O http://superb-east.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.20.tar.gz<br />
curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz<br />
curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz<br />
curl -O http://www.libgd.org/releases/gd-2.0.35.tar.gz</code></p>
<p>Download these packages to a directory on your hard drive. The next thing you need to do is unpack these directories. Running this command will unpack all the directories you just downloaded.<br />
<code><br />
ls *gz | xargs -n 1 tar zxvf</code></p>
<p>First, we will install zlib by running the commands below.</p>
<p><code>cd zlib-1.2.3<br />
./configure --shared<br />
make<br />
sudo make install</code></p>
<p>Next, install libpng by running the commands below.<br />
<code><br />
cd ../libpng-1.2.20<br />
cp scripts/makefile.darwin Makefile</code></p>
<p>Open up Makefile in your favorite text editor and edit the file to read as follows.</p>
<p><code># Where the zlib library and include files are located<br />
ZLIBLIB=/usr/local/lib<br />
ZLIBINC=/usr/local/include<br />
#ZLIBLIB=../zlib<br />
#ZLIBINC=../zlib</code></p>
<p>Then finish the install.<br />
<code><br />
make<br />
sudo make install</code></p>
<p>Test this by running the following code.<br />
<code><br />
export srcdir=.<br />
./test-pngtest.sh</code></p>
<p>Next install libjpeg.</p>
<p><code>cd ../jpeg-6b/<br />
ln -s `which glibtool` ./libtool<br />
export MACOSX_DEPLOYMENT_TARGET=10.4<br />
./configure --enable-shared<br />
make<br />
sudo make install</code></p>
<p>Now install freetype2.<br />
<code><br />
cd ../freetype-2.3.5</code></p>
<p>Open <code>include/freetype/config/ftoption.h</code> in your favorite editor and uncomment line 461 to read as follows.</p>
<p><code>#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER</code></p>
<p>Then complete the install.</p>
<p><code>./configure<br />
make<br />
sudo make install</code></p>
<p>Finally install GD.</p>
<p><code>cd ../gd-2.0.35<br />
ln -s `which glibtool` ./libtool<br />
./configure</code></p>
<p>The report looked like this when I did it.</p>
<p><code>Support for PNG library:          yes<br />
Support for JPEG library:         yes<br />
Support for Freetype 2.x library: yes<br />
Support for Fontconfig library:   no<br />
Support for Xpm library:          no<br />
Support for pthreads:             yes</code></p>
<p>Then finish the install.</p>
<p><code>make<br />
sudo make install</code></p>
<p>You can test it with the following code.</p>
<p><code>./gdtest test/gdtest.png<br />
open test/*.jpg</code></p>
<p>To add support for Fontconfig, run this command.</p>
<p><code>export GDFONTPATH=$HOME/Library/Fonts:/Library/Fonts:/System/Library/Fonts</code></p>
<p>To complete the installation, you need to recomple PHP with all the libraries you just installed. Here is how I did it.</p>
<p><code>./configure \<br />
--with-zlib-dir=/usr/local/lib \<br />
--with-jpeg-dir=/usr/local/lib \<br />
--with-png-dir=/usr/local/lib \<br />
--with-gd \<br />
--with-mysql=/usr/local/mysql \<br />
--with-apxs</code></p>
<p><code>make<br />
sudo make install</code></p>
<p>Now you should have PHP with GDLIB installed. That&#8217;s it. You&#8217;re done! Now, on to your next project!</p>
<img src="http://kempwire.com/?ak_action=api_record_view&id=110&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kempwire.com/tips/installing-gd-graphics-library-on-mac-os-x.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
