我也在我的 Mac 上进行 Django 开发,但找到了一个更好的解决方案(允许轻松使用 pip)使用 Vagrant + VirtualBox + Chef 在本地 VM 中安装 Django(这将允许您复制生产服务器设置)。然后,您可以在本地浏览器上访问它。这里有一个很好的介绍:
http://blog.smalleycreative.com/tutorials/setup-a-django-vm-with-vagrant-virtualbox-and-chef/
我已经更新了教程提供的 vagrantfile 以使用新的 Ubuntu 版本、包括 emacs、python 和 MySQL 客户端。我希望这有帮助。
需要额外的 git repos:
git clone git://github.com/opscode-cookbooks/emacs
git clone git://github.com/opscode-cookbooks/python
git clone git://github.com/opscode-cookbooks/mysql
和流浪文件:
Vagrant::Config.run do |config|
config.vm.define :djangovm do |django_config|
# Every Vagrant virtual environment requires a box to build off of.
django_config.vm.box = "precise32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
django_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
django_config.vm.forward_port 80, 8080
django_config.vm.forward_port 8000, 8001
# Enable provisioning with chef solo, specifying a cookbooks path (relative
# to this Vagrantfile), and adding some recipes and/or roles.
#
django_config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "apache2::mod_wsgi"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "vim"
chef.add_recipe "emacs"
chef.add_recipe "python"
chef.add_recipe "mysql"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
end
end
end