我目前有一台运行iis 7.5的Windows 2008网络服务器。我已成功为Python 2.7.4构建PyISAPIe 1.1.0。 Django已经部署,它可以快速运行。但据我所知,PyISAPIe在某种程度上是老式的,在2010年的最后一个版本发布。我发现有Helicon Zoo(运行WSGI桥的WebPI打包)和DjangoWindowsTools(使用Fascgi自动部署)。所以我想问你的建议:哪种解决方案最适合IIS上的django / python?
答案 0 :(得分:4)
我可以看到你找到了一个解决方案。您可能想知道Helicon Zoo还支持FastCGI协议进行操作(与Microsoft FCGI模块无关)。此外,它支持TCP协议(如Linux上的Nginx),对于彗星和长轮询支持非常有用。此外,它还提供了许多Microsoft FCGI模块所没有的附加功能,如自动负载平衡和应用程序扩展,慢速POST攻击保护等等。使用Web Platform Installer和Helicon Zoo,我可以收缩您的初始bat文件。请查看:
rem Default settings
SET SITE_NAME=Django Site
SET SITE_PHYSIC_PATH=C:\intepub\%SITE_NAME%
SET SITE_URL=*
SET SITE_PORT=8000
SET SITE_PROTOCOL=http
SET SITE_NAME="Enter site name (%SITE_NAME%):" %=%
SET /p SITE_PHYSIC_PATH="Enter project directory, which contain manage.py (%SITE_PHYSIC_PATH%): " %=%
SET /p SITE_PROTOCOL="Enter http|https for protocol (%SITE_PROTOCOL%): " %=%
SET /p SITE_URL="Enter site url (%SITE_URL%):" %=%
IF "%SITE_URL%"=="localhost" (
SET SITE_URL="*"
)
ECHO.
ECHO Install IIS, Python, Helicon Zoo and other requirements if needed
WebpiCmd.exe /Install /Products:PythonModules /feeds:http://www.helicontech.com/zoo/feed/ /AcceptEula
ECHO.
ECHO Create IIS Site: %SITE_NAME%
md %SITE_PHYSIC_PATH%
%windir%\system32\inetsrv\appcmd add site /name:"%SITE_NAME%" /physicalPath:"%SITE_PHYSIC_PATH%" /bindings:%SITE_PROTOCOL%://%SITE_URL%:%SITE_PORT%
%windir%\system32\inetsrv\appcmd start site /site.name:"%SITE_NAME%"
ECHO.
ECHO Create Django application
echo ApplicationPath[@]%SITE_NAME%/>DjangoProject.app
WebpiCmd.exe /Install /Application:ZooDjangoProject@DjangoProject.app /feeds:http://www.helicontech.com/zoo/feed/ /AcceptEula
如果需要,此代码还可以在完整的干净系统上安装IIS,Python,Helicon Zoo和所有其他要求。您只需要Web平台安装程序,您可以从安装它的其他系统中复制它通常位于 C:\ Program Files \ Microsoft \ Web Platform Installer 无需安装。
答案 1 :(得分:3)
好吧,经过另一项研究,我发现Windows Azure服务器使用FastCGI,设置非常简单。没有更多下载,构建......你可以在这里看到http://www.windowsazure.com/en-us/develop/python/tutorials/web-app-with-django/
我已经创建了一个自动安装程序。它正在使用iis 7.5在Windows seerver 2008 r2上运行。 从这里http://pytools.codeplex.com/releases
抓取wfastcgi.py@ECHO OFF
rem Check for IIS setup
IF NOT EXIST %windir%\system32\inetsrv\appcmd.exe (
ECHO Please have IIS 7.5 install first
GOTO END
)
rem Default settings
SET PYTHON_EXE="C:\Python27\python.exe"
SET PROJECT_NAME="DjangoProject"
SET SITE_NAME="%PROJECT_NAME%"
SET SITE_PHYSIC_PATH=%~dp0
SET SITE_URL="*"
SET SITE_PORT="8000"
SET SITE_PROTOCOL="http"
SET DJANGO_SETTING="%PROJECT_NAME%.settings"
rem Gathering information
ECHO IIS 7.5 Django Setup
ECHO Author: James spyjamesbond0072003@gmail.com
ECHO ===========================================
ECHO.
SET /p PYTHON_EXE="Enter python.exe path (%PYTHON_EXE%):" %=%
SET /p PROJECT_NAME="Enter project name (%PROJECT_NAME%):" %=%
SET SITE_NAME="%PROJECT_NAME%"
SET DJANGO_SETTING="%PROJECT_NAME%.settings"
SET /p SITE_PHYSIC_PATH="Enter project directory, which contain manage.py (%SITE_PHYSIC_PATH%): " %=%
SET /p DJANGO_SETTING="Django settings module (%DJANGO_SETTING%):" %=%
SET /p SITE_NAME="Enter IIS site name (%PROJECT_NAME%):" %=%
SET /p SITE_PROTOCOL="Enter http|https for protocol (%SITE_PROTOCOL%): " %=%
SET /p SITE_URL="Enter site url (%SITE_URL%):" %=%
IF "%SITE_URL%"=="localhost" (
SET SITE_URL="*"
)
SET /p SITE_PORT="Enter port (%SITE_PORT%):" %=%
SET WFCGI_FILE="%SITE_PHYSIC_PATH%\wfastcgi.py"
IF NOT EXIST %WFCGI_FILE% (
SET /p WFCGI_FILE="Please enter full path for wfastcgi.py: " %=%
)
ECHO =====================================
ECHO Installing
ECHO Install FASTCGI for IIS. Please wait.
start /wait %windir%\System32\PkgMgr.exe /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI;IIS-CGI
ECHO.
ECHO Create IIS Site: %SITE_NAME%
%windir%\system32\inetsrv\appcmd add site /name:%SITE_NAME% /physicalPath:%SITE_PHYSIC_PATH% /bindings:%SITE_PROTOCOL%/%SITE_URL%:%SITE_PORT%:
%windir%\system32\inetsrv\appcmd start site /site.name:%SITE_NAME%
ECHO.
ECHO Setup Python FastCGI Handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI "/+[fullPath='%PYTHON_EXE%', arguments='%WFCGI_FILE%']"
ECHO.
ECHO Register the handler for this site
%windir%\system32\inetsrv\appcmd set config "%SITE_NAME%" /section:system.webServer/handlers "/+[name='Python_via_FastCGI',path='*',verb='*',modules='FastCgiModule',scriptProcessor='%PYTHON_EXE%|%WFCGI_FILE%',resourceType='Unspecified']" /commit:site
ECHO.
ECHO Configure the handler to run your Django application
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PYTHON_EXE%', arguments='%WFCGI_FILE%'].environmentVariables.[name='DJANGO_SETTINGS_MODULE',value='k6ecommerce.settings']" /commit:apphost
ECHO.
ECHO Configure PYTHONPATH so your Django app can be found by the Python interpreter
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PYTHON_EXE%', arguments='%WFCGI_FILE%'].environmentVariables.[name='PYTHONPATH',value='%SITE_PHYSIC_PATH%']" /commit:apphost
ECHO.
ECHO Tell the FastCGI to WSGI gateway which WSGI handler to use:
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%PYTHON_EXE%', arguments='%WFCGI_FILE%'].environmentVariables.[name='WSGI_HANDLER',value='django.core.handlers.wsgi.WSGIHandler()']" /commit:apphost
ECHO.
ECHO Restart IIS
iisreset
ECHO Done...
:END