<?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>Notes of a Developer &#187; Django</title>
	<atom:link href="http://www.developers-life.com/tag/django/feed" rel="self" type="application/rss+xml" />
	<link>http://www.developers-life.com</link>
	<description>Develop on Objective-C, UIKit, C, OpenGL for  iPhone, iPad, Mac OS X</description>
	<lastBuildDate>Fri, 03 Feb 2012 11:49:47 +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>Setup Python, MySQL, MySQL-python and SVN on MAC OS X 10.6</title>
		<link>http://www.developers-life.com/setup-python-mysql-mysql-python-and-svn-on-mac-os-x-106.html</link>
		<comments>http://www.developers-life.com/setup-python-mysql-mysql-python-and-svn-on-mac-os-x-106.html#comments</comments>
		<pubDate>Sun, 11 Oct 2009 12:58:03 +0000</pubDate>
		<dc:creator>Vladimir Boychentsov</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[others]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SVN]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.developers-life.com/?p=550</guid>
		<description><![CDATA[Mac Os X + Python 2.6.1+ PIL + apache2.2 +mod_python + MySQL + MySQLdb +php5+ phpMyAdmin + SVN server +WebSVN OS: Mac OS X 10.6.1 Snow Leopard XCode:The latest Xcode Tools Python: Python 2.6.1 64-bit (Snow Leopard default) Projects will be located in ~/Sites, so change permissions: add read permission for everyone on ~/Sites Setup [...]]]></description>
			<content:encoded><![CDATA[<p>Mac Os X + Python 2.6.1+ PIL + apache2.2 +mod_python + MySQL + MySQLdb +php5+ phpMyAdmin + SVN server +WebSVN</p>
<p>OS: Mac OS X 10.6.1 Snow Leopard<br />
XCode:The latest Xcode Tools<br />
Python: Python 2.6.1 64-bit (Snow Leopard default)</p>
<p>Projects will be located in ~/Sites, so change permissions:<br />
     add read permission for everyone on ~/Sites</p>
<p>Setup django</p>
<p>   1.    mkdir  ~/sources<br />
   2.    cd ~/sources<br />
   3.    svn co http://code.djangoproject.com/svn/django/trunk/ django<br />
   4.    cd django<br />
   5.    sudo python setup.py install</p>
<p>Apache:<br />
    We will use default 10.6 apache2.2</p>
<p>Setup mod_python:<br />
   1.  mkdir  ~/sources/mod_python<br />
   2.  cd ~/sources/mod_python<br />
   3.  svn co http://svn.apache.org/repos/asf/quetzalcoatl/mod_python/trunk mod_python-trunk<br />
   4.  cd mod_python-trunk<br />
   5.  ./configure &#8211;with-apxs=/usr/sbin/apxs<br />
   6.  make<br />
   7.  sudo make install</p>
<p><span id="more-550"></span><br />
Setup MySQL &#8212; Download 64bit!!!<br />
  1. nano  ~/.profile<br />
   2. export PATH=&#8221;/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH&#8221;<br />
   3. source ~/.profile<br />
   4. Download MySQL 5.1.39 sourcse and place it into ~/sources<br />
   5. tar xzvf mysql-5.1.39.tar.gz<br />
   6. cd mysql-5.1.39</p>
<p>    7.  ./configure &#8211;prefix=/usr/local/mysql &#8211;with-extra-charsets=complex \<br />
         &#8211;enable-thread-safe-client &#8211;enable-local-infile &#8211;enable-shared \<br />
         &#8211;with-plugins=innobase<br />
    8. make<br />
    9. sudo make install<br />
    10. cd /usr/local/mysql<br />
    11. sudo ./bin/mysql_install_db &#8211;user=mysql<br />
    12. sudo chown -R mysql ./var<br />
    13. cd ..<br />
    14. open TexEdit, switch to plain text<br />
            copy-paste:</p>
<div class="codecolorer-container objc geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&lt;?xml version<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;1.0&quot;</span> encoding<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;UTF-8&quot;</span>?&gt;<br />
&lt;<span style="color: #002200;">!</span>DOCTYPE plist PUBLIC <span style="color: #bf1d1a;">&quot;-//Apple//DTD PLIST 1.0//EN&quot;</span> <span style="color: #bf1d1a;">&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;</span>&gt;<br />
&lt;plist version<span style="color: #002200;">=</span><span style="color: #bf1d1a;">&quot;1.0&quot;</span>&gt;<br />
&lt;dict&gt;<br />
&nbsp; &nbsp; &lt;key&gt;KeepAlive&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #a61390;">true</span><span style="color: #002200;">/</span>&gt;<br />
&nbsp; &nbsp; &lt;key&gt;Label&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;string&gt;com.mysql.mysqld&lt;<span style="color: #002200;">/</span>string&gt;<br />
&nbsp; &nbsp; &lt;key&gt;Program&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;string&gt;<span style="color: #002200;">/</span>usr<span style="color: #002200;">/</span>local<span style="color: #002200;">/</span>mysql<span style="color: #002200;">/</span>bin<span style="color: #002200;">/</span>mysqld_safe&lt;<span style="color: #002200;">/</span>string&gt;<br />
&nbsp; &nbsp; &lt;key&gt;RunAtLoad&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #a61390;">true</span><span style="color: #002200;">/</span>&gt;<br />
&nbsp; &nbsp; &lt;key&gt;UserName&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;string&gt;mysql&lt;<span style="color: #002200;">/</span>string&gt;<br />
&nbsp; &nbsp; &lt;key&gt;WorkingDirectory&lt;<span style="color: #002200;">/</span>key&gt;<br />
&nbsp; &nbsp; &lt;string&gt;<span style="color: #002200;">/</span>usr<span style="color: #002200;">/</span>local<span style="color: #002200;">/</span>mysql&lt;<span style="color: #002200;">/</span>string&gt;<br />
&lt;<span style="color: #002200;">/</span>dict&gt;<br />
&lt;<span style="color: #002200;">/</span>plist&gt;</div></td></tr></tbody></table></div>
<p>save as ~/sources/com.mysql.mysqld.plist<br />
close TexEdit</p>
<p>    15. sudo mv ~/sources/com.mysql.mysqld.plist /Library/LaunchDaemons<br />
    16. sudo chown root /Library/LaunchDaemons/com.mysql.mysqld.plist<br />
    17. sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysqld.plist<br />
    18. mysqladmin -u root password NEW_PASSWORD</p>
<p>Setup MySQL for Python adapter</p>
<p>   1. Download the latest MySQL for Python adapter from SourceForge(http://sourceforge.net/project/showfiles.php?group_id=22307) and copy to ~/sources<br />
   2. cd ~/sources<br />
   3. tar xzvf MySQL-python-1.2.2.tar.gz<br />
   4. cd ./MySQL-python-1.2.2<br />
   5. Inside the folder, clean the package by typing<br />
   6. sudo python setup.py clean<br />
   7. In the same folder, edit _mysql.c using your favourite text-editor<br />
   8. Remove the following lines (37-39):</p>
<div class="codecolorer-container python geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#ifndef uint</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#define uint unsigned int</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">#endif</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;Change the following:<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;uint port <span style="color: #66cc66;">=</span> MYSQL_PORT<span style="color: #66cc66;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;uint client_flag <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><span style="color: #66cc66;">;</span> <br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;to<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp;unsigned <span style="color: #008000;">int</span> port <span style="color: #66cc66;">=</span> MYSQL_PORT<span style="color: #66cc66;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;unsigned <span style="color: #008000;">int</span> client_flag <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><span style="color: #66cc66;">;</span></div></td></tr></tbody></table></div>
<p>9. Create a symbolic link under lib to point to a sub-directory called mysql. This is where it    looks for during compilation.<br />
    10.sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql<br />
    11. Edit the setup_posix.py and change the following<br />
         mysql_config.path = &#8220;mysql_config&#8221;<br />
          to<br />
     mysql_config.path = &#8220;/usr/local/mysql/bin/mysql_config&#8221;<br />
     12.In the same directory, rebuild your package (ignore the warnings that comes with it)</p>
<p>     13. sudo python setup.py build</p>
<p>       Install the package and you are done.</p>
<p>     14. sudo python setup.py install</p>
<p>      Test if it&#8217;s working. It works if you can import MySQLdb.</p>
<p>      python<br />
    >>> import MySQLdb</p>
<p> SVN<br />
   We will be using build in svn  + WebSvn for repo browsing<br />
   1. mkdir ~/svn<br />
   2 cd ~<br />
   3.chown -R _www svn<br />
   4. svnadmin create &#8211;fs-type fsfs myrepo-1<br />
   5. donwload latest WebSVN<br />
   6. Unpack in into ~/Sites<br />
   7. rename to websvn<br />
   8. chmod 0700 ~/Sites/websvn/cache<br />
   9. rename ~/Sites/websvn/include/distconfig.php to ~/Sites/websvn/include/config.php<br />
   10. edit ~/Sites/websvn/include/config.php:<br />
               find and uncomment<br />
         $config-&gt;useTreeIndex(true);  // Tree index, open by default<br />
         $config-&gt;addInlineMimeType(&#8220;text/plain&#8221;);<br />
         $config-&gt;hideRSS();<br />
         $config-&gt;parentPath(&#8216;path/to/yours/svn&#8217;);</p>
<p> Starting project<br />
   1. cd ~/Sites<br />
   2. mkdir Temp<br />
   3. chmod 0700  ~/Sites/Temp<br />
   4. django-admin.py start project my_project<br />
   5. nano apache_settings.py<br />
   6. add lines:</p>
<div class="codecolorer-container python geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">os</span>.<span style="color: black;">environ</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'PYTHON_EGG_CACHE'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'/Users/you_user_name/Sites/Temp'</span><br />
&nbsp; &nbsp;close apache_settings.<span style="color: black;">py</span></div></td></tr></tbody></table></div>
<p>Configure Apache:<br />
      sudo nano /etc/apache2/httpd.conf<br />
      Add lines:<br />
      LoadModule python_module  libexec/apache2/mod_python.so<br />
      LoadModule php5_module libexec/apache2/libphp5.so #for WebSvn and phpMyAdmin<br />
      Uncomment:<br />
      Include /private/etc/apache2/extra/httpd-vhosts.conf<br />
      Add line:<br />
      PythonImport /Users/you_user_name/Sites/my_project/apache_settings.py my_project<br />
save and exit httpd.conf</p>
<p>Configure VirtualHosts:<br />
      sudo nano /etc/apache2/extra/httpd-vhosts.conf<br />
      remove all lines<br />
      add</p>
<div class="codecolorer-container apache geshi" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:810px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span><br />
&nbsp; &nbsp; <br />
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">ServerName</span> <span style="color: #7f007f;">&quot;you_server_name&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/pyromann/Sites/my_project&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">ErrorLog</span> &nbsp; &nbsp; <span style="color: #7f007f;">&quot;/private/var/log/apache2/my_project-error_log&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">CustomLog</span> &nbsp; <span style="color: #7f007f;">&quot;/private/var/log/apache2/my_project-access_log&quot;</span> common<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Users/pyromann/Sites/my_project&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">FollowSymLinks</span> MultiViews <span style="color: #0000ff;">Includes</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span><br />
&nbsp; &nbsp; &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;<br />
<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight:bold;">Location</span> <span style="color: #7f007f;">&quot;/&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">SetHandler</span> python-program<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">SetEnv</span> &nbsp;DJANGO_SETTINGS_MODULE my_project.settings<br />
&nbsp; &nbsp; &nbsp; &nbsp; PythonHandler django.core.handlers.modpython<br />
&nbsp; &nbsp; &nbsp; &nbsp; PythonPath <span style="color: #7f007f;">&quot;sys.path + ['/Users/your_user_name/Sites/']&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PythonOption django.root /my_project<br />
&nbsp; &nbsp; &nbsp; &nbsp; PythonDebug <span style="color: #0000ff;">On</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; PythonInterpreter my_project<br />
&nbsp; &nbsp; &lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;<br />
<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight:bold;">Location</span> <span style="color: #7f007f;">&quot;/media&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">SetHandler</span> <span style="color: #0000ff;">None</span><br />
&nbsp; &nbsp; &lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;<br />
<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight:bold;">LocationMatch</span> <span style="color: #7f007f;">&quot;.(jpg|gif|png)$&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">SetHandler</span> <span style="color: #0000ff;">None</span><br />
&nbsp; &nbsp; &lt;/<span style="color: #000000; font-weight:bold;">LocationMatch</span>&gt;<br />
<br />
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;<br />
<br />
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">ServerName</span> <span style="color: #7f007f;">&quot;mysqladmin.loc&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">ServerAlias</span> <span style="color: #7f007f;">&quot;www.mysqladmin.loc&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/your_user_name/Sites/mysqladmin&quot;</span><br />
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;<br />
<br />
<br />
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">ServerName</span> <span style="color: #7f007f;">&quot;svn.loc&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">ServerAlias</span> <span style="color: #7f007f;">&quot;www.svn.loc&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/Users/your_user_name/Sites/websvn&quot;</span><br />
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</div></td></tr></tbody></table></div>
<p>Setup hosts<br />
   sudo nano /etc/hosts<br />
   add line:<br />
   127.0.0.1 your_server_name svn.loc mysqladmin.loc</p>
<p>restart apache<br />
    sudo apachectl restart<br />
    http://svn.loc &#8211; yours svn<br />
    http://mysqladmin.loc &#8211; phpMyAdmin<br />
    http://your_server_name  &#8211; yours django project</p>
<p> setup PIL<br />
    Download lates sources<br />
    Place it to ~/sources<br />
    tar xzfv Imaging-1.1.6.tar<br />
    cd Imaging-1.1.6<br />
    python setup.py build<br />
    sudo python setup.py install</p>
<p>Source:<br />
<noindex><br />
<a href="http://pyromann-dude.blogspot.com/2009/09/how-to-setup-django-development.html">How to setup django development environment in Mac OS X 10.6 Snow Leopard</a></noindex></p>
]]></content:encoded>
			<wfw:commentRss>http://www.developers-life.com/setup-python-mysql-mysql-python-and-svn-on-mac-os-x-106.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

