James
James

Reputation:

Looking to get started with Apache, PHP, MySQL, Python, Django on a fresh Mac

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

Upvotes: 1

Views: 5579

Answers (6)

Adam Nelson
Adam Nelson

Reputation: 8090

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.

Upvotes: 0

dlamblin
dlamblin

Reputation: 45321

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

Upvotes: -1

user41767
user41767

Reputation: 1217

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

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

Upvotes: 0

user75832
user75832

Reputation:

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

Upvotes: 0

Tyson
Tyson

Reputation: 6244

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

Upvotes: 6

Adrian Archer
Adrian Archer

Reputation: 2323

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

Upvotes: 1

Related Questions