views:

1497

answers:

7

I've looked for other questions, but could not find any...

I have freshly installed my Mac with OSX 10.5. I need to learn Python/Django for a new job, so want to set it all up correctly, ready to develop and run from my browser using http://localhost/

I come from a PHP background and always used MAMP before. But I want to get everything working together... Apache, PHP, MySQL, Python, Django. Using MAMP is easy to install a local development server, but I want to get Python and Django running nicely too. So I can just start developing and also following tutorials on Python/Django.

Please give me some steps (with MAMP or not) to get a nicely working environment for Apache, PHP, MySQL, Python and Django. Thank you, all have great days!

James

+1  A: 

Your Mac should come pre-installed with Python 2.4 (or later) which is fine for Django 1.0.2.

Adrian Archer
+1: And has Apache, also.
S.Lott
+6  A: 

Why not try the official installation instructions? Really all you need to do is install Django. You can use its built-in server (http://localhost:8000 by default) for testing:

./manage.py runserver
Tyson
I second that... the shell output in the official install instructions even show that the person who wrote it was using a mac on leopard.
Jarret Hardie
Because the official instructions rely on the macports version. Which means you must have Xcode and X11; I mean that's a lot of requirements for a "just trying things out" web scripter. And if he goes the source route, there's no hints on getting it working with MySQL.
dlamblin
Oh, but the MySQL driver does require a C compiler, and hence Xcode.
dlamblin
+1: Quote the documentation
S.Lott
If you just want to learn Django, I'd recommend using SQLite -- it makes it a bit easier. If you're going to use it in production, then you'd want to look at a more robust database like PostgreSQL.
Tyson
A: 

10.5 comes with Apache installed by default System Preferences > Sharing > Web Sharing.

To enable Apache php module edit the Apache conf (/etc/Apache/httpd.conf) file and uncomment the php module line.

LoadModule php5_module libexec/apache2/libphp5.so.

Restart Apache after by disabling & enabling web sharing

Mysql package can be downloaded form the official website and is easy to install

Ben Reeves
A: 

Okay. I'd just install MySQL from their site and stick with what's already on my Mac as of 10.5, then install Django and the Python MySQL driver. But since you like MAMP, install MAMP or XAMPP and read something like this which summarized says:

Mac OS X 10.5 comes with "Python 2.5.1, thus you won’t have to install it. You can verify this by running python in the Terminal."

Checkout Django cd $HOME/Code; svn co http://code.djangoproject.com/svn/django/trunk django_trunk

Tell Python where Django is echo "$HOME/Code/django_trunk">/Library/Python/2.5/site-packages/django.pth

Add django-admin.py to your PATH

Install the MySQLdb driver from sf.net this probably requires GCC which means you might want the set with Xcode from Apple's Dev Tools.

Do a source code edit

"At this point, edit the _mysql.c file and comment out lines 37, 38 and 39 as follows:"

//#ifndef uint
//#define uint unsigned int
//#endif

run

python setup.py build
sudo python setup.py install

Verify the installation

dlamblin
A: 

The fastest way to get started with Django, will be to use TurnKey linux Django appliance.

Link: http://www.turnkeylinux.org/appliances/django

A: 

I also came from PHP a few months ago. I'm not sure if this will get moderated up or down because my answer changes your question:

  1. Do not use MySQL and Apache for local development on your Mac. Use Sqlite3 and the development server that is bundled with Django - this allows for inline debugging, etc...
  2. Sqlite3 is basically the same as MySQL except you need to use .schema instead of describe.
  3. If you start having problems, get MacPython. This has helped me instantly solve problems faster than trying to work with the stock Python on Leopard.
  4. Try to use pip instead of easy_install where possible.

When you are ready for real deployment, then you'll need MySQL/Apache/Nginx, etc... but those will be on a Linux system and you'll be better prepared at that point to make a good production installation than you are now. Getting a production-quality stack running on the Mac is more of a pain than it's worth.

BTW, when you do install Apache, use wsgi, not mod_python.

Adam Nelson
A: 

Hi James,

This guide may be useful for you....

http://thirdpartycode.com/2009/02/using-your-mac-as-a-local-web-development-environment/

JeeCare.

JeeCare