我可以在 Windows 上使用 XAMPP 运行 Django(Python 框架)基础站点吗?请指导我。
5 回答
XAMPP for windows 包含:Apache, MySQL, PHP + PEAR, Perl, mod_php
, mod_perl
, mod_ssl
, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite , 和 WEB-DAV + mod_auth_mysql
.
缺少运行 django 有两个要求:
所以,不,你不能单独使用 XAMPP 运行 django。您需要安装其他软件。
但是运行 django 非常容易。如果你只是想开发一个应用程序,你只需要python和django。Django 本身包含一个可用于开发的内部 Web 服务器。
如果你想在 Windows 上使用 django 作为生产服务器,你甚至不需要 apache web 服务器。你可以只安装:
这足以让一个好的 django 生产服务器启动并运行,因为cherrypy 的 web 服务器是用 python 编写的,并且非常适合为 django(或任何其他wsgi兼容的)应用程序提供服务。如果您没有将 apache 用于其他任何事情,我认为此设置实际上更好更容易。您可以使用其他网络服务器来代替cherrypy。但是如果你真的想使用 apache,你还需要mod_wsgi
.
The running django on xampp can be divided into two steps.
- Step 1 : install wsgi and check if everything is OK
- follow the steps in the answer of this post - Setting Python Path in Windows XAMPP using WSGI
- Step 2 : install and run django
- run easy_install django to install django on PC
- test django
- follow the example in "http://docs.djangoproject.com/en/dev/intro/tutorial01/"
- I assume the generated django code is in C:\xampp\htdocs\django\mysite
- Make the mysite.wsgi in C:\xampp\htdocs\wsgi\scripts
mysight.wsgi
import os
import sys
mysite = r'C:/xampp/htdocs/django'
if mysite not in sys.path:sys.path.insert(0,mysite)
mysite = r'C:/xampp/htdocs/django/mysite'
if mysite not in sys.path:sys.path.insert(0,mysite)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
- You can add WSGIScriptAlias /mysite "C:/xampp/htdocs/wsgi/scripts/mysite.wsgi" in wsgi.conf to run http://YOURSITE/mysite, or you can just run http://YOURSITE/wsgi/mysite.wsgi
- Relaunch apache if necessary.
我不确定你想要什么,所以这可能不是一个正确的答案。
如果您只想(为自己)运行一个开发服务器,使用 Django 框架提供的 Web 服务器会更容易。在书中阅读更多相关信息:http: //www.djangobook.com/en/2.0/chapter02/
您可能想签出 DjangoStack。它类似于 XAMPP,它是免费的、多平台的和自包含的,但它默认安装了 Django。
是的,你可以,但首先你必须安装 Python 和 mod_python。请参阅此常见问题解答。
然而,出于开发目的,使用内置的 Django 开发服务器要容易得多。这将更容易使用和设置以帮助您入门。