<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>fornOObs.info</title>
	
	<link>http://fornoobs.info</link>
	<description>web use and web dev</description>
	<lastBuildDate>Mon, 24 May 2010 08:25:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Fornoobsinfo" /><feedburner:info uri="fornoobsinfo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>ImportError: No module named web</title>
		<link>http://fornoobs.info/2010/05/importerror-no-module-named-web/</link>
		<comments>http://fornoobs.info/2010/05/importerror-no-module-named-web/#comments</comments>
		<pubDate>Mon, 24 May 2010 08:20:30 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web.py]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=354</guid>
		<description><![CDATA[You landed on this page because you are trying to get started with web.py but you are stomped with an error called &#8220;ImportError: No module named web&#8221;. The tutorial on webpy.org is straightforward, but the first hurdle in installing web.py on your system can get very frustrating when you encounter errors. For this post, I [...]]]></description>
			<content:encoded><![CDATA[<p>You landed on this page because you are trying to get started with web.py but you are stomped with an error called &#8220;ImportError: No module named web&#8221;. </p>
<p>The tutorial on webpy.org is straightforward, but the first hurdle in installing web.py on your system can get very frustrating when you encounter errors. For this post, I am assuming that you have already installed web.py either via downloading the tar.gz then running &#8216;python setup.py&#8217; or via the MacPorts/DarwinPorts or via &#8216;easy_install web.py&#8217;, or via &#8216;apt-get install python-webpy&#8217;&#8212;there are instructions on how to install web.py elsewhere on the web, I suggest start with <a href="http://webpy.org/install">webpy.org/install</a> page.</p>
<p>To test if your installation of web.py has succeeded, open up a Terminal window and start an interactive Python session.</p>
<pre class="command">
$ python
>>> import web
>>>
</pre>
<p>After inputting the command &#8216;import web&#8217; on the Python interpreter, you should not see any other message, Python should quietly return you to the >>> prompt, this means that Python has successfully found the module named &#8216;web&#8217;, your installation of web.py has succeeded. You wouldn&#8217;t be visiting this page though if this was the case, you are here most likely because, what you saw was this.</p>
<pre class="command">
$ python
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import web
Traceback (most recent call last):
  File "stdin", line 1, in module
ImportError: No module named web
>>>
</pre>
<p>This error means that the Python interpreter cannot find the module named <strong>web</strong>&#8212;specifically, what it cannot find is </p>
<p class="note">
/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg
</p>
<p>&#8216;web.py-0.34-py2.6.egg&#8217; is a directory which has been created/installed when you tried to install web.py (using either MacPorts/DarwinPorts, apt-get or easy_install), inside that directory is another directory named &#8216;web&#8217;, that directory is actually what you were trying to import using the command </p>
<p class="note">
>>> import web
</p>
<p>I am not entirely sure what causes the ImportError problem, but it sure sounds like a PYTHONPATH issue. </p>
<h2>Quick fix</h2>
<p>Just add the <strong>web.py-0.34-py2.6.egg</strong> into your PYTHONPATH variable, there are several ways of doing this, you can export the PYTHONPATH as a shell variable or you can append to the PYTHONPATH either on interactive Python session or inside YourPythonCode.py.</p>
<p>On the interactive Python interpreter.</p>
<pre class="command">
$ python
>>> import sys
>>> sys.path.append('/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg')
>>> import web
>>>
</pre>
<p>Appending the the PYTHONPATH in your code</p>
<pre class="note">
import sys
sys.path.append('/Library/Python/2.6/site-packages/web.py-0.34-py2.6.egg')
import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:
    def GET(self, name):
        if not name:
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()
</pre>
<p>You should be able to proceed now and get started with web.py</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/" rel="bookmark" class="crp_title">PHP5 and WordPress 2.8 (It&#8217;s not safe to rely on the system&#8217;s time zone)</a></li><li><a href="http://fornoobs.info/2009/11/printing-line-numbers-of-a-source-using-python/" rel="bookmark" class="crp_title">Printing line numbers of a source using Python</a></li><li><a href="http://fornoobs.info/2009/07/small-example-on-using-sqlite-and-python/" rel="bookmark" class="crp_title">Small example on using SQLite and Python</a></li><li><a href="http://fornoobs.info/2009/07/getting-started-with-python-and-mysql/" rel="bookmark" class="crp_title">Getting started with Python and MySQL</a></li><li><a href="http://fornoobs.info/2009/06/7-hours-and-counting-waiting-for-the-web-to-be-reinveted/" rel="bookmark" class="crp_title">7 hours and counting&#8211;waiting for the web to be reinvented</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2010/05/importerror-no-module-named-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>gem install ERROR: While executing gem … (Errno::EEXIST) on Windows 7 x64</title>
		<link>http://fornoobs.info/2010/04/gem-install-error-while-executing-gem-errnoeexist-on-windows-7-x64/</link>
		<comments>http://fornoobs.info/2010/04/gem-install-error-while-executing-gem-errnoeexist-on-windows-7-x64/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 02:39:32 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=350</guid>
		<description><![CDATA[&#8220;gem install rails&#8221; won&#8217;t complete the installation on Windows 7 64-bit when executed on the command line with non-administrator rights. Create a short-cut to your Windows 7 desktop for cmd.exe, right click cmd on the desktop and &#8220;Run as Administrator&#8221;&#8211;then type gem install rails After doing this, the installation of rails via gem continued without [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;gem install rails&#8221; won&#8217;t complete the installation on Windows 7 64-bit when executed on the command line with non-administrator rights. </p>
<p>Create a short-cut to your Windows 7 desktop for cmd.exe, right click cmd on the desktop and &#8220;Run as Administrator&#8221;&#8211;then type</p>
<p class="command">
gem install rails
</p>
<p>After doing this, the installation of rails via gem continued without problems.</p>
<pre class="note">
Some notes:

GEM version = 1.3.6 (you can get this using 'gem -v')
Ruby version = 1.8.7
Windows platform = Windows 7 Professional
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2010/05/importerror-no-module-named-web/" rel="bookmark" class="crp_title">ImportError: No module named web</a></li><li><a href="http://fornoobs.info/2009/06/installing-apache-mysql-and-php-on-windows/" rel="bookmark" class="crp_title">Installing Apache, MySQL and PHP on Windows</a></li><li><a href="http://fornoobs.info/2009/07/getting-started-with-python-and-mysql/" rel="bookmark" class="crp_title">Getting started with Python and MySQL</a></li><li><a href="http://fornoobs.info/2009/06/where-exactly-is-the-apache-document-root/" rel="bookmark" class="crp_title">Where exactly is the Apache document root</a></li><li><a href="http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">wp-config.php problem on Snow Leopard (OSX 10.6.1)</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2010/04/gem-install-error-while-executing-gem-errnoeexist-on-windows-7-x64/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fornoobs.info is undergoing some maintenance work</title>
		<link>http://fornoobs.info/2010/02/fornoobs-info-is-undergoing-some-maintenance-work/</link>
		<comments>http://fornoobs.info/2010/02/fornoobs-info-is-undergoing-some-maintenance-work/#comments</comments>
		<pubDate>Sat, 20 Feb 2010 11:31:20 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=346</guid>
		<description><![CDATA[Apologies for the few people who visits fornoobs.info, the domain and hosting expired today&#8211;and has slipped through my calendar. I&#8217;ve activated it since then, but there are some problems accessing the posts. I&#8217;m sorting it out at the moment. Related Posts:First postTiming of postingThis has got to be unique to meMaking a copy of Live [...]]]></description>
			<content:encoded><![CDATA[<p>Apologies for the few people who visits fornoobs.info, the domain and hosting expired today&#8211;and has slipped through my calendar. I&#8217;ve activated it since then, but there are some problems accessing the posts. I&#8217;m sorting it out at the moment.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/06/first-post/" rel="bookmark" class="crp_title">First post</a></li><li><a href="http://fornoobs.info/2009/07/timing-of-posting/" rel="bookmark" class="crp_title">Timing of posting</a></li><li><a href="http://fornoobs.info/2009/06/this-has-got-to-be-unique-to-me/" rel="bookmark" class="crp_title">This has got to be unique to me</a></li><li><a href="http://fornoobs.info/2009/10/making-a-copy-of-live-wordpress-posts-in-a-local-environment/" rel="bookmark" class="crp_title">Making a copy of Live WordPress posts in a local environment</a></li><li><a href="http://fornoobs.info/2009/10/install-git-on-osx/" rel="bookmark" class="crp_title">Install git on OSX</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2010/02/fornoobs-info-is-undergoing-some-maintenance-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read a file line by line with Python</title>
		<link>http://fornoobs.info/2009/11/read-a-file-line-by-line-with-python/</link>
		<comments>http://fornoobs.info/2009/11/read-a-file-line-by-line-with-python/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 11:58:03 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[file handling]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=337</guid>
		<description><![CDATA[You can use this code when you need to walk through any text file line by line. This is especially useful when processing log files or any other file where you need to perform a specific action when certain conditions are met. The sys.argv[1] reads the first parameter that was passed from the command line. [...]]]></description>
			<content:encoded><![CDATA[<p>You can use this code when you need to walk through any text file line by line. This is especially useful when processing log files or any other file where you need to perform a specific action when certain conditions are met.  </p>
<script src="http://gist.github.com/235151.js"></script><noscript><code class="gist"><pre></p>
<p>import sys</p>
<p>for line in open(sys.argv[1],&#8217;r'):<br />
	print line<br />
</pre></code></noscript>
<p>The sys.argv[1] reads the first parameter that was passed from the command line. The &#8216;r&#8217; value which is the second parameter of the open function means you are opening the file for reading. This code only prints whatever line has been read currently in the for-loop, you can substitute or insert your other processing needs such as looking for specific text patterns (using the python re) etc.</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/11/printing-line-numbers-of-a-source-using-python/" rel="bookmark" class="crp_title">Printing line numbers of a source using Python</a></li><li><a href="http://fornoobs.info/2010/05/importerror-no-module-named-web/" rel="bookmark" class="crp_title">ImportError: No module named web</a></li><li><a href="http://fornoobs.info/2009/07/small-example-on-using-sqlite-and-python/" rel="bookmark" class="crp_title">Small example on using SQLite and Python</a></li><li><a href="http://fornoobs.info/2009/10/send-mail-in-python/" rel="bookmark" class="crp_title">Send mail in Python</a></li><li><a href="http://fornoobs.info/2009/07/getting-started-with-python-and-mysql/" rel="bookmark" class="crp_title">Getting started with Python and MySQL</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/11/read-a-file-line-by-line-with-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing line numbers of a source using Python</title>
		<link>http://fornoobs.info/2009/11/printing-line-numbers-of-a-source-using-python/</link>
		<comments>http://fornoobs.info/2009/11/printing-line-numbers-of-a-source-using-python/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 11:18:33 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[file handling]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=331</guid>
		<description><![CDATA[Sharing your codes with other programmers often requires that you reference the code itself. If the code is short enough it may not be much of an issue referring to it&#8217;s individual lines or if you loaded the code in a programmer&#8217;s editor like TextMate or Eclipse etc, which can display line numbers. Displaying line [...]]]></description>
			<content:encoded><![CDATA[<p>Sharing your codes with other programmers often requires that you reference the code itself. If the code is short enough it may not be much of an issue referring to it&#8217;s individual lines or if you loaded the code in a programmer&#8217;s editor like TextMate or Eclipse etc, which can display line numbers. </p>
<p>Displaying line numbers in your code becomes specially problematic when you need to display it on a web page and when it&#8217;s several lines long. While you can use one of the so-many plugins or javascript libraries, you can usually whip up your own solution to displaying line numbers in the code that you&#8217;d like to share. </p>
<h2>Printing your source file with line numbers</h2>
<p>There are many ways to solve this challenge using some of the code pretty printers and document generators out there, but usually, you can whip up your own. This solution uses Python. You need to have Python in your system, and you need to work on this using the command line. Launch your favorite program editor, create file named printlinenumber.py, then type the following code and save it.</p>
<script src="http://gist.github.com/235149.js"></script><noscript><code class="gist"><pre></p>
<p>import sys</p>
<p>counter = 0<br />
for line in open(sys.argv[1],&#8217;r'):<br />
	counter = counter + 1<br />
	print counter, line,</p>
<p></pre></code></noscript>
<p>This is a basic file handling code in Python. First, it reads a parameter from the command line (sys.argv[1]), then it opens it up in read only mode (&#8216;r&#8217;). After that, the code steps through each line of the file using a for-loop, and finally printing an incremented counter, then printing the line which has been currently processed by the for-loop. </p>
<p>The comma after &#8216;line&#8217; is added because Python basically adds a &#8216;\n&#8217; when you use the print command, the comma suppresses it. </p>
<p>A sample usage of this solution is </p>
<p class="command">
$ python printlinenumber.py MySourceFile.any > temp.txt
</p>
<p>Just replace MySourceFile.any with the source file that you&#8217;d like to process. The &#8216;>&#8217; is the redirection operator (works in Linux/UNIX/Windows which essentially dumps the results to temp.txt</p>
<h2>Embedding it in your webpages</h2>
<p>You can pretty much just copy-paste the contents of temp.txt and embed it inside a pre (preformatted) html tag. </p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/07/well-known-port-numbers/" rel="bookmark" class="crp_title">Well known port numbers</a></li><li><a href="http://fornoobs.info/2009/11/read-a-file-line-by-line-with-python/" rel="bookmark" class="crp_title">Read a file line by line with Python</a></li><li><a href="http://fornoobs.info/2009/06/7-hours-and-counting-waiting-for-the-web-to-be-reinveted/" rel="bookmark" class="crp_title">7 hours and counting&#8211;waiting for the web to be reinvented</a></li><li><a href="http://fornoobs.info/2010/05/importerror-no-module-named-web/" rel="bookmark" class="crp_title">ImportError: No module named web</a></li><li><a href="http://fornoobs.info/2009/10/send-mail-in-python/" rel="bookmark" class="crp_title">Send mail in Python</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/11/printing-line-numbers-of-a-source-using-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP5 and WordPress 2.8 (It’s not safe to rely on the system’s time zone)</title>
		<link>http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/</link>
		<comments>http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 14:25:43 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://fornoobs.info/?p=314</guid>
		<description><![CDATA[After installing another test rig for WordPress (2.8) on Snow Leopard, there is a weird error. *** Warning: strtotime() [function.strtotime]: It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still [...]]]></description>
			<content:encoded><![CDATA[<p>After installing another test rig for WordPress (2.8) on Snow Leopard, there is a weird error. </p>
<p>***</p>
<p>Warning: strtotime() [function.strtotime]: It is not safe to rely on the system&#8217;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier &#8230;</p>
<p>*** </p>
<p>This has got something to do with PHP5&#8242;s increased reporting level, they are just warnings though, but the user can see it. </p>
<h2>The fix</h2>
<p>Open up /etc/php.ini&#8211;if you haven&#8217;t edited php.ini before, you need to make a copy of it first</p>
<p class="command">
$ cd /etc<br />
$ sudo cp php.ini.default php.ini
</p>
<p>Edit php.ini and look for the line &#8216;date.timezone&#8217;. You may need to use sudo or login as root when you make this change because /etc/php.ini is owned by root.</p>
<pre class="note">
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone =
</pre>
<p>It&#8217;s blank, fill up with your appropriate timezone, i.e. &#8216;Asia/Manila&#8217;, &#8216;America/New_York&#8217; etc. </p>
<pre class="note">
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = 'America/Los_Angeles'
</pre>
<p>The value for the timezone above that I&#8217;ve used is valid if you are on Pacific time. You can get the <a href="http://www.php.net/manual/en/timezones.php">timezone values here</a>, look up your appropriate timezone value, then make the changes as shown above.</p>
<p>Save the file. You will need to restart Apache to activate the changes you made to php.ini</p>
<p class="command">
$ sudo /usr/sbin/apachectl restart
</p>
<p>Try to see if you still see the date warning. </p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">PHP5 not enabled by default  in Snow Leopard (OSX 10.6.1)</a></li><li><a href="http://fornoobs.info/2009/06/not-safe-for-work/" rel="bookmark" class="crp_title">Not safe for work</a></li><li><a href="http://fornoobs.info/2009/06/wordpress-2-8-upgrade/" rel="bookmark" class="crp_title">WordPress 2.8 upgrade</a></li><li><a href="http://fornoobs.info/2009/10/making-a-copy-of-live-wordpress-posts-in-a-local-environment/" rel="bookmark" class="crp_title">Making a copy of Live WordPress posts in a local environment</a></li><li><a href="http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">wp-config.php problem on Snow Leopard (OSX 10.6.1)</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple Installation – Apache, MySQL, PHP on Snow Leopard</title>
		<link>http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/</link>
		<comments>http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 05:56:15 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/</guid>
		<description><![CDATA[Apache,MySQL and PHP is straightforward to install in OSX, in the past though, MySQL was probably a bit challenging to install on OSX, because it required downloading the source, adding the mysql group from the shell and changing permissions of some files&#8211;that has changed. You can install MySQL in OSX using a .dmg package. By [...]]]></description>
			<content:encoded><![CDATA[<p>Apache,MySQL and PHP is straightforward to install in OSX, in the past though, MySQL was probably a bit challenging to install on OSX, because it required downloading the source, adding the mysql group from the shell and changing permissions of some files&#8211;that has changed. You can install MySQL in OSX using a .dmg package.</p>
<p>By the way, there is a package called MAMP (Mac Apache MysQL PHP), and can be downloaded from <a href="http://www.mamp.info/en/index.html" title="MAMP site">mamp.info</a>, this guide will not be using the MAMP package. This guide details the installation/configuration of Apache2, MySQL 5 and PHP5 in OSX (Snow Leopard to be specific) using freely available software and software which are already in your OSX&#8211;PHP5 and Apache2 are actually included in OSX, it just needs a little bit of configuration.</p>
<p>Here are the steps on installing Apache+MySQL+PHP in OSX.</p>
<h2>To install Apache and PHP</h2>
<p>Snow Leopard comes with Apache and PHP, but you need to enable them&#8211;here&#8217;s how to do it.</p>
<p>1. Launch System Preferences.</p>
<p><img src="http://fornoobs.info/wp-content/uploads/2009/10/System-Preferences.png" width="535" height="449" alt="System Preferences.png" /></p>
<p>2. Click &#8216;Sharing&#8217;</p>
<p><img src="http://fornoobs.info/wp-content/uploads/2009/10/Sharing-Preferences.png" width="538" height="440" alt="Sharing Preferences.png" /></p>
<p>3. Enable &#8216;Web Sharing&#8217; from the Sharing preferences window. This action activates the Apache web server. To test it, you can launch Safari, go to http://localhost, when you see the &#8220;it Works!&#8221; welcome message that means Apache is running. Now type http://localhost/~&lt;yourUserNameInHere&gt; (of course, replace youUserNameInHere with, well&#8211;your Mac user name); that URL you just typed is mapped to /User/YourUserName/Sites folder, if you want to replace (or add) the content of that URL, you will need to edit /User/YourUserName/Sites/index.html</p>
<p>To enable PHP in OSX</p>
<p>Launch the Terminal.app (just use SpotLight, cmd + space bar, then type Terminal, then enter), then type</p>
<p class="command">$ sudo nano /etc/apache2/httpd.conf</p>
<p>httpd.conf is owned by the root user, hence you can only read it but not modify&#8211;we need to modify httpd.conf though, that is the reason why there is a &#8216;sudo&#8217; in the command; sudo temporarily allows you to have superuser or root privileges. It will ask you for a password, don&#8217;t worry because it&#8217;s not asking for the root password, it&#8217;s asking for your password. By the way, nano is a text editor, it&#8217;s not as sexy as TextEdit or TextMate, but it&#8217;s quite handy specially if you need to work on the command line a lot&#8211;vi or emacs will do too, if you know how to use it. I use nano a lot that&#8217;s why it&#8217;s what I used here.</p>
<p>The apache configuration file (httpd.conf) is a big file, it&#8217;s a bit intimidating too if you&#8217;re editing it for the first time, so you might want to back it up first before pressing on any further. You can quit nano for now (CTRL X), then on the Terminal.app, type</p>
<p class="command">
$ cd /etc/apache2<br />
$ sudo cp httpd.conf httpd.conf.copy
</p>
<p>I&#8217;m just making a copy of the original file, just in case we mess something up, we have a way of restoring the original Apache configuration.</p>
<p>Okay, back to editing httpd.conf, open it up again with nano</p>
<p>$ sudo nano httpd.conf</p>
<script src="http://gist.github.com/240518.js"></script><noscript><code class="gist"><pre></p>
<p>LoadModule dav_module libexec/apache2/mod_dav.so<br />
LoadModule status_module libexec/apache2/mod_status.so<br />
LoadModule autoindex_module libexec/apache2/mod_autoindex.so<br />
LoadModule asis_module libexec/apache2/mod_asis.so<br />
LoadModule info_module libexec/apache2/mod_info.so<br />
LoadModule cgi_module libexec/apache2/mod_cgi.so<br />
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so<br />
LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so<br />
LoadModule negotiation_module libexec/apache2/mod_negotiation.so<br />
LoadModule dir_module libexec/apache2/mod_dir.so<br />
LoadModule imagemap_module libexec/apache2/mod_imagemap.so<br />
LoadModule actions_module libexec/apache2/mod_actions.so<br />
LoadModule speling_module libexec/apache2/mod_speling.so<br />
LoadModule userdir_module libexec/apache2/mod_userdir.so<br />
LoadModule alias_module libexec/apache2/mod_alias.so<br />
LoadModule rewrite_module libexec/apache2/mod_rewrite.so<br />
LoadModule bonjour_module     libexec/apache2/mod_bonjour.so<br />
LoadModule php5_module        libexec/apache2/libphp5.so<br />
#LoadModule fastcgi_module     libexec/apache2/mod_fastcgi.so</p>
<p><IfModule !mpm_netware_module><br />
<IfModule !mpm_winnt_module><br />
#<br />
# If you wish httpd to run as a different user or group, you must run<br />
# httpd as root initially and it will switch.<br />
#<br />
# User/Group: The name (or #number) of the user/group to run httpd as.<br />
# It is usually good practice to create a dedicated user and group for<br />
# running httpd, as with most system services.<br />
#<br />
User _www<br />
Group _www</p>
<p></IfModule><br />
</IfModule></p>
<p># &#8216;Main&#8217; server configuration</p>
<p></pre></code></noscript>
<p>The code responsible for enabling PHP in in OSX is &#8220;LoadModule php5_module&#8221;, this is somewhere line #116 in httpd.conf, you could slowly scroll down to it using the down arrow key or you could use the search function in nano (CTRL W, then type php) it will take you to this line.</p>
<p>At the moment, the line is commented out, it has a pound (#) sign prepended to it, you will need to remove that pound sign to enable PHP. After you have removed the pound sign, save httpd.conf now (CTRL O), then exit nano (CTRL X)</p>
<p>You will need to restart Apache so that our configuration changes can take effect.</p>
<h3>Restarting / troubleshooting apache</h3>
<p>You can now restart your apache setup, try to see if PHP is already enabled. When I first wrote this post, it didn&#8217;t occur to me that some errors might creep in, I&#8217;ve been installing apache for a long time now, and I probably got used to some of it&#8217;s quirks&#8211;but some users encountered errors, and they were kind enough to let me know&#8211;that&#8217;s why I&#8217;ve added this small section on troubleshooting apache and restarting apache. </p>
<p>Apache in Snow Leopard has a server control interface, the executable file is called apachectl, you can view a lot more information about by doing an &#8216;$info apachectl&#8217; from the Terminal.app. Here are some quick things you can do with it.</p>
<p class="command">$ sudo apachectl restart</p>
<p>Obviously that is how to restart apache<br />
If for whatever reason, apachectl is not within your PATH, you can fully qualify the command with</p>
<p class="command">$ sudo /usr/sbin/apachectl restart</p>
<p>Apache and PHPare now enabled.</p>
<p>Here are some more</p>
<p class="note">
$ sudo apachectl stop //to stop apache gracefully<br />
$ sudo apachectl start //starts apache, this actually loads httpd<br />
$ sudo apachectl configtest //run this if you are having problems with apache, this is a verbose mode of starting the apache service, very useful if you suspect that apache cannot fully load and start.<br />
$ sudo apachectl -k start //I picked this up from BAT (see comments below), starts apache in a verbose way too.
</p>
<h3>Testing PHP</h3>
<p>You can create a basic test for PHP by writing a small piece of code. </p>
<p class="command">
$ cd ~<br />
$ echo &#8220;<? php phpinfo() ?>&#8221; > test.php
</p>
<p>Launch your browser, then point it to &#8216;http://localhost/~YourUserNameHere/test.php&#8217;, if you see the famous phpinfo information page, then you&#8217;re already done&#8211;you have now setup PHP with Apache. </p>
<h2>Installing MySQL in Snow Leopard</h2>
<p>The installer package for MySQL can be downloaded from <a href="http://dev.mysql.com/downloads/mysql/5.1.html" title="MySQL 5.1 download page">MySQL.com</a>, there are 2 options for download, one is in package format and other is in tar packages), just download the package format, so that it will install MySQL in an OSX-ish way (with dialog boxes and just clicking next, next and next).</p>
<p>After the install has finished, MySQL will now have an entry in the System Preferences window, you can launch System Preferences again, then click MySQL (it will be right at the bottom of System Preferences)</p>
<p>
<img src="http://fornoobs.info/wp-content/uploads/2009/10/System-Preferences1.png" width="576" height="483" alt="System Preferences.png" /></p>
<p>Click MySQL. It will restart System Preferences (a bit annoying actually), but just go ahead and do it.</p>
<p>
<img src="http://fornoobs.info/wp-content/uploads/2009/10/MySQL-preferences.png" width="523" height="259" alt="MySQL preferences.png" /></p>
<p>From this window, you can start | stop MySQL manually. You also have the option the Automatically start MySQL whenever your Mac is started.</p>
<p>Just a quick test to see if everything is in order. Go back to your Terminal.app, and let&#8217;s take MySQL out for a little spin.</p>
<p class="command">
$ mysql -u root -p<br />
mysql> show databases;<br />
 mysql> show tables;<br />
mysql> quit<br />
 $</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">wp-config.php problem on Snow Leopard (OSX 10.6.1)</a></li><li><a href="http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">PHP5 not enabled by default  in Snow Leopard (OSX 10.6.1)</a></li><li><a href="http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/" rel="bookmark" class="crp_title">PHP5 and WordPress 2.8 (It&#8217;s not safe to rely on the system&#8217;s time zone)</a></li><li><a href="http://fornoobs.info/2009/06/installing-apache-mysql-and-php-on-windows/" rel="bookmark" class="crp_title">Installing Apache, MySQL and PHP on Windows</a></li><li><a href="http://fornoobs.info/2009/06/how-to-install-wordpress/" rel="bookmark" class="crp_title">How to install WordPress</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP5 not enabled by default  in Snow Leopard (OSX 10.6.1)</title>
		<link>http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/</link>
		<comments>http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 13:07:13 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[server]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/</guid>
		<description><![CDATA[To enable PHP5 in Snow Leopard, you need to edit the Apache2 configuration file httpd.conf, you will find it in 2 places; first is in /private/etc/apache2/httpd.conf (surprisingly, PHP5 was enabled in this file, but Apache wasn&#8217;t processing php still)&#8211;the second place is in /etc/apache2/httpd.conf. Edit /etc/apache2/httpd.conf using any editor you like. If you are using [...]]]></description>
			<content:encoded><![CDATA[<p>To enable PHP5 in Snow Leopard, you need to edit the Apache2 configuration file httpd.conf, you will find it in 2 places; first is in /private/etc/apache2/httpd.conf (surprisingly, PHP5 was enabled in this file, but Apache wasn&#8217;t processing php still)&#8211;the second place is in /etc/apache2/httpd.conf.</p>
<p>Edit /etc/apache2/httpd.conf using any editor you like. If you are using TextMate, here are the steps:</p>
<ol>
<li>Launch Terminal.app (it&#8217;s inside /Applications/Utilities folder)</li>
<li>On the Terminal, type &#8220;sudo mate /etc/apache2/httpd.conf&#8221;, you need to type sudo because httpd.conf is owned by root, and you won&#8217;t be able to edit without super user privileges. It will ask you for a password&#8211;it&#8217;s actually asking for your password, not root&#8217;s, so just type your password to satisfy the challenge.</li>
</ol>
<p>If you don&#8217;t have TextMate, just use nano, here are the steps:</p>
<ol>
<li>Launch Terminal.app</li>
<li>Type &#8220;sudo nano /etc/apache2/httpd.conf&#8221; &#8212; you already know the reason for sudo.</li>
</ol>
<p>Now that httpd.conf is open, scroll down, or better yet, use the find function of your editor&#8211;(CTRL W in nano)&#8211;and find the line &#8220;#LoadModule php5_module&#8221;, this around line 116 in httpd.conf</p>
<p>Remove the pound (#) sign and save the file (CTRL O in nano). Exit the editor (CTRL X in nano) then restart Apache.</p>
<p class="command">$ sudo apachectl restart</p>
<p>if apachectl is not within your PATH (which is unlikely), you can fully qualify the command</p>
<p class="command">$ sudo /usr/sbin/apachectl restart</p>
<p>PHP5 should now be enabled in Snow Leopard. Go ahead, test it out with phpinfo()</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/" rel="bookmark" class="crp_title">PHP5 and WordPress 2.8 (It&#8217;s not safe to rely on the system&#8217;s time zone)</a></li><li><a href="http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/" rel="bookmark" class="crp_title">Simple Installation &#8211; Apache, MySQL, PHP on Snow Leopard</a></li><li><a href="http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">wp-config.php problem on Snow Leopard (OSX 10.6.1)</a></li><li><a href="http://fornoobs.info/2009/06/where-exactly-is-the-apache-document-root/" rel="bookmark" class="crp_title">Where exactly is the Apache document root</a></li><li><a href="http://fornoobs.info/2009/10/install-git-on-osx/" rel="bookmark" class="crp_title">Install git on OSX</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wp-config.php problem on Snow Leopard (OSX 10.6.1)</title>
		<link>http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/</link>
		<comments>http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 12:36:11 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[wordpress]]></category>
		<category><![CDATA[mysql error]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/</guid>
		<description><![CDATA[The usual 5 minute installation of WordPress 2.8.x is a bit weird on Snow Leopard (10.6) —right after downloading http://www.wordpress.org/latest.zip, unzipped it in ~/Sites/wpstaging (that’s the name I chose to my WordPress development environment), created the database in MySQL, GRANTed the privilege of a wordpress user so that it can have access to the database, [...]]]></description>
			<content:encoded><![CDATA[<p>The usual 5 minute installation of WordPress 2.8.x is a bit weird on Snow Leopard (10.6) —right after downloading http://www.wordpress.org/latest.zip, unzipped it in ~/Sites/wpstaging (that’s the name I chose to my WordPress development environment), created the database in MySQL, GRANTed the privilege of a wordpress user so that it can have access to the database, then copied wp-config.php.sample to wp-config.php and editing wp-config.php to reflect the proper values—There is a database connection error! I’ve installed WordPress many many times in the past; by hand, so I’m certain that it’s not my usual user error.</p>
<p>Double checking and triple checking wp-config.php didn’t change a thing, the config entries are fine—so I thought.</p>
<p>The DB_HOST entry seems to be at fault, after changing the DB_HOST value to 127.0.0.1:3306, explicitly specifying the port which MySQL uses, the database connection error problem suddenly disappeared, and I was able to proceed with the usual WordPress configuration</p>
<p>
<img src="http://fornoobs.info/wp-content/uploads/2009/10/WordPress-configuration.png" width="559" height="412" alt="WordPress-configuration.png" /></p>
<p>Here’s the snippet of the wp-config.</p>
<pre class="note">
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wpstaging');

/** MySQL database username */
define('DB_USER', 'wpstaging');

/** MySQL database password */
define('DB_PASSWORD', 'wpstaging');

/** MySQL hostname */
define('DB_HOST', '127.0.0.1:3306');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
</pre>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/10/php5-not-enabled-by-default-in-snow-leopard-osx-10-6-1/" rel="bookmark" class="crp_title">PHP5 not enabled by default  in Snow Leopard (OSX 10.6.1)</a></li><li><a href="http://fornoobs.info/2009/06/how-to-install-wordpress/" rel="bookmark" class="crp_title">How to install WordPress</a></li><li><a href="http://fornoobs.info/2009/11/php5-and-wordpress-2-8-its-not-safe-to-rely-on-the-systems-time-zone/" rel="bookmark" class="crp_title">PHP5 and WordPress 2.8 (It&#8217;s not safe to rely on the system&#8217;s time zone)</a></li><li><a href="http://fornoobs.info/2009/10/simple-installation-apache-mysql-php-on-snow-leopard/" rel="bookmark" class="crp_title">Simple Installation &#8211; Apache, MySQL, PHP on Snow Leopard</a></li><li><a href="http://fornoobs.info/2009/07/solr-in-tomcat/" rel="bookmark" class="crp_title">Solr in Tomcat</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/10/wp-config-php-problem-on-snow-leopard-osx-10-6-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decided to continue working on the WordPress Stubborn theme</title>
		<link>http://fornoobs.info/2009/10/decided-to-continue-working-on-the-wordpress-stubborn-theme/</link>
		<comments>http://fornoobs.info/2009/10/decided-to-continue-working-on-the-wordpress-stubborn-theme/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 14:12:54 +0000</pubDate>
		<dc:creator>Ted Heich</dc:creator>
				<category><![CDATA[stubborn-theme]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[wordpress theme]]></category>

		<guid isPermaLink="false">http://fornoobs.info/2009/10/decided-to-continue-working-on-the-wordpress-stubborn-theme/</guid>
		<description><![CDATA[Stubborn theme found a home in github—I’ve always wanted to try github and learn git anyway—so this is perfect fit, I get to continue working on the Stubborn theme while using git for configuration management. There are bits and pieces of the Stubborn theme which, right now, from hindsight, I don’t like as much as [...]]]></description>
			<content:encoded><![CDATA[<p>Stubborn theme found a home in <a href="http://github.com/tedheich/wptheme-stubborn">github</a>—I’ve always wanted to try github and learn git anyway—so this is perfect fit, I get to continue working on the Stubborn theme while using git for configuration management.</p>
<p>There are bits and pieces of the Stubborn theme which, right now, from hindsight, I don’t like as much as I liked before. I think it should still be minimalistic, one-column and plain—but probably, no longer loud. I think it needs a bit more restraint and should conservatively follow usability rules. </p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://fornoobs.info/2009/07/a-bit-of-a-requirements-process-for-wordpress-theming/" rel="bookmark" class="crp_title">A bit of a requirements process for WordPress theming</a></li><li><a href="http://fornoobs.info/2009/06/coding-the-blog-front-page/" rel="bookmark" class="crp_title">Coding the blog front page</a></li><li><a href="http://fornoobs.info/2009/06/basic-checklist-for-project-preparation/" rel="bookmark" class="crp_title">Basic checklist for project preparation</a></li><li><a href="http://fornoobs.info/2009/10/making-a-copy-of-live-wordpress-posts-in-a-local-environment/" rel="bookmark" class="crp_title">Making a copy of Live WordPress posts in a local environment</a></li><li><a href="http://fornoobs.info/2009/06/how-to-install-wordpress/" rel="bookmark" class="crp_title">How to install WordPress</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://fornoobs.info/2009/10/decided-to-continue-working-on-the-wordpress-stubborn-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
