<?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>david winter &#187; macports</title>
	<atom:link href="http://davidwinter.me.uk/articles/tag/macports/feed/" rel="self" type="application/rss+xml" />
	<link>http://davidwinter.me.uk</link>
	<description>you were expecting someone else?</description>
	<lastBuildDate>Mon, 28 Jun 2010 20:37:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Installing MySQL for PHP with MacPorts</title>
		<link>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/</link>
		<comments>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 13:38:02 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=162</guid>
		<description><![CDATA[In my other howto, I installed Apache, PHP and MongoDB. I now need to setup MySQL so that I can develop a WordPress theme and plugin on my local machine. Here are the few steps I used: sudo port install mysql5-server sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist sudo -u _mysql mysql_install_db5 sudo chown -R _mysql:_mysql /opt/local/var/db/mysql5/ [...]]]></description>
			<content:encoded><![CDATA[<p>In my other howto, I installed Apache, PHP and MongoDB. I now need to setup MySQL so that I can develop a WordPress theme and plugin on my local machine. Here are the few steps I used:</p>

<p><span id="more-162"></span></p>

<pre><code>sudo port install mysql5-server
sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist
sudo -u _mysql mysql_install_db5
sudo chown -R _mysql:_mysql /opt/local/var/db/mysql5/ 
sudo chown -R _mysql:_mysql /opt/local/var/run/mysql5/ 
sudo chown -R _mysql:_mysql /opt/local/var/log/mysql5/
</code></pre>

<p>I then add the following aliases to make it easy to start, stop and restart MySQL:</p>

<pre><code>mate ~/.bashrc

alias mysql-start="sudo /opt/local/share/mysql5/mysql/mysql.server start"
alias mysql-restart="sudo /opt/local/share/mysql5/mysql/mysql.server restart"
alias mysql-stop="sudo /opt/local/share/mysql5/mysql/mysql.server stop"

source ~/.profile
</code></pre>

<p>You can then use the following to start MySQL:</p>

<pre><code>mysql-start
</code></pre>

<p><em>Note: I had errors when I first tried starting MySQL. This was because I&#8217;d installed a version of MySQL previously from the official site and it was conflicting. Removing the old version of MySQL did the trick &#8211; instructions <a href="http://tomkeur.net/39/how-to-remove-mysql-completely-mac-os-x-leopard.html">here</a>.</em></p>

<p>When you start the server, it&#8217;s best to set the <code>root</code> user password:</p>

<pre><code>mysqladmin5 -u root password mysupersecretpassword
</code></pre>

<p>Then to setup PHP to work with MySQL:</p>

<pre><code>sudo port install php5-mysql
</code></pre>

<p>Then update the php.ini file:</p>

<pre><code>sudo nano /opt/local/etc/php5/php.ini
</code></pre>

<p>And ensure this line is in there:</p>

<pre><code>mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock
</code></pre>

<p>Restart Apache, and then you&#8217;re all set.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2010/02/28/installing-mysql-for-php-with-macports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache, PHP and MongoDB on Mac OS X 10.6 Snow Leopard</title>
		<link>http://davidwinter.me.uk/articles/2010/01/02/apache-php-and-mongodb-on-mac-os-x-10-6-snow-leopard/</link>
		<comments>http://davidwinter.me.uk/articles/2010/01/02/apache-php-and-mongodb-on-mac-os-x-10-6-snow-leopard/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 13:12:13 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=152</guid>
		<description><![CDATA[MongoDB (from &#8220;humongous&#8221;) is a scalable, high-performance, open source, schema-free, document-oriented database. There&#8217;s a lot of buzz brewing about it, so I wanted to give it a try with PHP on my development Mac. The following is how I went about installing Apache, PHP and MongoDB on Snow Leopard. You must have installed the Xcode [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mongodb.org/display/DOCS/Home">MongoDB</a> (from &#8220;humongous&#8221;) is a scalable, high-performance, open source, schema-free, document-oriented database.</p>

<p>There&#8217;s a lot of <a href="http://delicious.com/search?p=mongodb&amp;chk=&amp;context=popular|&amp;fr=del_icio_us&amp;lc=">buzz</a> brewing about it, so I wanted to give it a try with PHP on my development Mac. The following is how I went about installing Apache, PHP and MongoDB on Snow Leopard. You must have installed the <a href="[http://developer.apple.com/tools/xcode/">Xcode</a> developer tools (found on the Snow Leopard install DVD) and <a href="[http://www.macports.org/">MacPorts</a> for this to all work.</p>

<p><span id="more-152"></span></p>

<p>First, let&#8217;s install Apache:</p>

<pre><code>sudo port install apache2
</code></pre>

<p>Nice and simple. Now we can move onto PHP:</p>

<pre><code>sudo port install php5 +apache2 +pear
</code></pre>

<p>To enable PHP for Apache:</p>

<pre><code>cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
</code></pre>

<p>I like to make some alias commands for starting, restarting and stopping Apache:</p>

<pre><code>mate ~/.bashrc

alias apache-start="sudo /opt/local/apache2/bin/apachectl start"
alias apache-restart="sudo /opt/local/apache2/bin/apachectl restart"
alias apache-stop="sudo /opt/local/apache2/bin/apachectl stop"

source ~/.bashrc
</code></pre>

<p>Now we can make a few changes to the Apache config so that we can use our Sites directory:</p>

<pre><code>sudo mate /opt/local/apache2/conf/httpd.conf
</code></pre>

<p>I&#8217;m using Textmate here (<code>mate</code>), but you can use any editor you wish, like <code>nano</code>.</p>

<p>Change the <code>DocumentRoot</code>:</p>

<pre><code>DocumentRoot "/Users/davidwinter/Sites"
</code></pre>

<p>Then update the <code>&lt;Directory&gt;</code> path to the updated <code>DocumentRoot</code> path.  </p>

<pre><code>&lt;Directory "/Users/davidwinter/Sites"&gt;
</code></pre>

<p>We also want to enable <code>index.php</code> as a directory index file:</p>

<pre><code>&lt;IfModule dir_module&gt;
    DirectoryIndex index.html index.php
&lt;/IfModule&gt;
</code></pre>

<p>And then add the PHP mime type:</p>

<pre><code>&lt;IfModule mime_module&gt;
    ...
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
&lt;/IfModule&gt;
</code></pre>

<p>Now we need to setup the <code>php.ini</code> file:</p>

<pre><code>sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini

sudo mate /opt/local/etc/php5/php.ini
</code></pre>

<p>My <a href="[http://php.net/manual/en/timezones.php">timezone</a> is for London:</p>

<pre><code>date.timezone = Europe/London
</code></pre>

<p>Now we can get onto installing MongoDB (this will install the latest stable version as of time of writing &#8211; 1.2.1): </p>

<pre><code>sudo port install mongodb
</code></pre>

<p>And then the PHP MongoDB extension:</p>

<pre><code>sudo pecl install mongo
</code></pre>

<p>You&#8217;ll need to add the extension to the bottom of your <code>php.ini</code> file:</p>

<pre><code>sudo mate /opt/local/etc/php5/php.ini

extension=mongo.so
</code></pre>

<p>Now startup Apache using the <code>alias</code> created earlier:</p>

<pre><code>apache-start
</code></pre>

<p>If you create a file in your Sites directory, called <code>test.php</code>, and add the following to it:</p>

<pre><code>&lt;?php phpinfo(); ?&gt;
</code></pre>

<p>Then visit the page in your browser; <a href="http://localhost/test.php">http://localhost/test.php</a></p>

<p>You can then scroll down the page and you should see a section titled &#8216;mongo&#8217;. This means the extension is working!</p>

<p>Now we need to startup MongoDB:</p>

<pre><code>mkdir -p ~/data/db
mongod --dbpath ~/data/db/
</code></pre>

<p>Almost there, now a simple MongoDB test in PHP:</p>

<pre><code>&lt;?php
// Connect:
$connection = new Mongo();
// Select database:
$db = $connection-&gt;my_db;
// Select collection:
$films = $db-&gt;films;

$frwl = array(
    'title' =&gt; 'From Russia With Love',
    'year' =&gt; 1963,
    'actor' =&gt; 'Sean Connery'
);
// Save array to collection:
$films-&gt;insert($frwl);

$gf = array(
    'title' =&gt; 'Goldfinger',
    'year' =&gt; 1964,
    'actor' =&gt; 'Sean Connery',
    'girl' =&gt; 'Pussy Galore'
);

$films-&gt;insert($gf);

// Count documents in collection:
if ($films-&gt;count()): ?&gt;
&lt;table&gt;
    &lt;tr&gt;
        &lt;th&gt;Title&lt;/th&gt;
        &lt;th&gt;Year&lt;/th&gt;
        &lt;th&gt;Actor&lt;/th&gt;
        &lt;th&gt;Girl&lt;/th&gt;
    &lt;/tr&gt;
    &lt;?php foreach ($films-&gt;find() as $film): ?&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;?php echo $film['title']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $film['year']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $film['actor']; ?&gt;&lt;/td&gt;
        &lt;td&gt;&lt;?php echo $film['girl']; ?&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;?php endforeach; ?&gt;
&lt;/table&gt;
&lt;?php endif;
?&gt;
</code></pre>

<p>Very exciting stuff. More to follow.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2010/01/02/apache-php-and-mongodb-on-mac-os-x-10-6-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Install pecl_http for PHP</title>
		<link>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/</link>
		<comments>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 21:33:41 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[macports]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[pecl_http]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://davidwinter.me.uk/?p=117</guid>
		<description><![CDATA[You will probably want to ensure that curl supports https before getting underway: curl -V Check that the output contains https: &#62;: curl -V curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3 Protocols: tftp ftp telnet dict http file https ftps Features: Largefile NTLM SSL libz If it doesn&#8217;t: sudo port deactivate curl sudo port install curl [...]]]></description>
			<content:encoded><![CDATA[<p>You will probably want to ensure that <code>curl</code> supports <code>https</code> before getting underway:</p>

<pre><code>curl -V
</code></pre>

<p>Check that the output contains <code>https</code>:</p>

<pre><code>&gt;: curl -V
curl 7.19.2 (i386-apple-darwin9.5.0) libcurl/7.19.2 OpenSSL/0.9.8i zlib/1.2.3
Protocols: tftp ftp telnet dict http file https ftps 
Features: Largefile NTLM SSL libz
</code></pre>

<p>If it doesn&#8217;t:</p>

<pre><code>sudo port deactivate curl
sudo port install curl +ssl
</code></pre>

<p>Once you have <code>curl</code> with <code>https</code> support:</p>

<pre><code>sudo pecl install pecl_http
</code></pre>

<p>If you followed my previous <a href="/articles/2008/11/22/php5-lighttpd-and-imagick-on-mac-os-x-leopard/">howto</a>, you&#8217;ll want to move the module to the location specified in your <code>php.ini</code> file:</p>

<pre><code>sudo cp /opt/local/lib/php/extensions/no-debug-non-zts-20060613/http.so /opt/local/lib/php/extensions
</code></pre>

<p>Restart <code>lighttpd</code> and then you&#8217;ll be good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://davidwinter.me.uk/articles/2008/11/24/install-pecl_http-for-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
