简体   繁体   English

在 Windows 上主持 Django 和 XAMPP

[英]Host Django with XAMPP on Windows

Can I run a Django (Python framework) base site with XAMPP on Windows?我可以在 Windows 上使用 XAMPP 运行 Django(Python 框架)基站点吗? Please guide me.请指导我。

XAMPP for windows contains: 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, and WEB-DAV + mod_auth_mysql . XAMPP for windows contains: 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

There are two requirements to run django missing:运行 django 缺少两个要求:

So, NO , you can't run django with XAMPP alone.所以,,你不能单独运行 django 和 XAMPP。 You need to install additional software.您需要安装额外的软件。

However running django is very easy.但是运行 django 非常容易。 If you just want to develop an application, you only need python and django. Django itself includes an internal web server that can be used for development.如果只是想开发一个应用,只需要python和django即可。Django本身包含一个内部的web服务器,可以用来开发。

If you want to use django on windows for a production server, you don't even need the apache web server.如果你想在 windows 上使用 django 作为生产服务器,你甚至不需要 apache web 服务器。 You could install just:您可以只安装:

That's enough to have a good django production server up and running, since cherrypy's web server is written in python and is pretty good to serve django (or any other wsgi -compatible) applications.这足以启动并运行一个好的 django 生产服务器,因为 cherrypy 的 web 服务器是用 python 编写的,非常适合服务 django(或任何其他wsgi兼容)应用程序。 If you're not using apache for anything else I think this setup is actually better and easier.如果您不将 apache 用于其他用途,我认为此设置实际上更好、更容易。 There are other webservers you could use instead of cherrypy.您可以使用其他网络服务器来代替 cherrypy。 But if you really want to use apache, you also need mod_wsgi .但是如果你真的要使用apache,你还需要mod_wsgi

The running django on xampp can be divided into two steps. xampp上运行django可以分为两步。

mysight.wsgi 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()

I'm not sure what you want, so this may not be a proper answer.我不确定你想要什么,所以这可能不是一个正确的答案。

If you just want to run a development server (for yourself), it would be easier to use a web server provided by Django framework.如果你只想运行一个开发服务器(为你自己),使用 Django 框架提供的 web 服务器会更容易。 Read more about that in the book: http://www.djangobook.com/en/2.0/chapter02/在书中阅读更多相关信息: http://www.djangobook.com/en/2.0/chapter02/

You may want to checkout DjangoStack .你可能想签出 DjangoStack It is similar to XAMPP in that is free, multiplatform and self-contained but it comes with Django installed by default.它类似于 XAMPP,因为它是免费的、多平台的和独立的,但它默认安装了 Django。

Yes, you can, but first you have to install Python and mod_python.是的,你可以,但首先你必须安装 Python 和 mod_python。 See this FAQ .请参阅 此常见问题解答

However for development purposes, it is far easier to use the built in Django development server.但是出于开发目的,使用内置的 Django 开发服务器要容易得多。 This will be much easier to use and setup to get you started.这将更易于使用和设置以帮助您入门。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM