1

我一直在寻找其他问题,但找不到任何问题...

我刚刚安装了带有 OSX 10.5 的 Mac。我需要为一份新工作学习 Python/Django,所以想要正确设置它,准备好使用http://localhost/从我的浏览器开发和运行

我来自 PHP 背景,之前一直使用 MAMP。但我想让所有东西一起工作……Apache、PHP、MySQL、Python、Django。使用 MAMP 很容易安装本地开发服务器,但我也想让 Python 和 Django 运行良好。所以我可以开始开发并遵循 Python/Django 的教程。

请给我一些步骤(无论是否使用 MAMP),以便为 Apache、PHP、MySQL、Python 和 Django 获得一个良好的工作环境。谢谢大家,祝大家天天开心!

詹姆士

4

6 回答 6

6

为什么不试试官方安装说明?实际上,您需要做的就是安装 Django。您可以使用其内置服务器(http://localhost:8000默认情况下)进行测试:

./manage.py runserver
于 2009-03-10T20:19:07.963 回答
1

你的 Mac 应该预装 Python 2.4(或更高版本),这对于 Django 1.0.2 来说很好。

于 2009-03-10T20:15:16.040 回答
0

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.

于 2009-03-11T16:04:48.970 回答
0

10.5 附带默认安装的 Apache 系统偏好设置 > 共享 > Web 共享。

要启用 Apache php 模块,请编辑 Apache conf (/etc/Apache/httpd.conf) 文件并取消注释 php 模块行。

LoadModule php5_module libexec/apache2/libphp5.so. 

通过禁用和启用网络共享重新启动 Apache

Mysql包可以从官网下载,安装方便

于 2009-03-10T20:25:13.020 回答
0

开始使用 Django 的最快方法是使用 TurnKey linux Django 设备。

链接:http ://www.turnkeylinux.org/appliances/django

于 2009-03-10T20:34:50.330 回答
-1

好的。我只是从他们的站点安装 MySQL 并坚持使用 10.5 版本的 Mac 上已有的内容,然后安装 Django 和 Python MySQL 驱动程序。但既然你喜欢 MAMP,请安装MAMPXAMPP并阅读类似这样的总结:

Mac OS X 10.5 附带“Python 2.5.1,因此您不必安装它。您可以通过在终端中运行 python 来验证这一点。”

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

告诉 Python Django 在哪里 echo "$HOME/Code/django_trunk">/Library/Python/2.5/site-packages/django.pth

将 django-admin.py 添加到您的 PATH

sf.net安装 MySQLdb 驱动程序,这可能需要 GCC,这意味着您可能需要使用 Apple 开发工具中的 Xcode 设置。

进行源代码编辑

“此时,编辑_mysql.c文件,将第37、38、39行注释掉如下:”

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

python setup.py build
sudo python setup.py install

验证安装

于 2009-03-10T20:26:55.620 回答