I am learning the process to deploy Django Project through IIS and fastCGI. However, I am facing an error <handler> scriptProcessor could not be found in <fastCGI> application configuration.
After a little bit of research I've found that this error could be due to rights issue. Hence I've added permission (read, write, execute) for user DefaultAppPool in folder Python37 (contains python virtual environment) and similarly I've done this for folder wwwroot which is on C:\inetpub.
Python Virtual Environment: C:\python37
Web.config file path: C:\inetpub\wwwroot\web.config
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Python FastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\python37\scripts\python.exe|c:\python37\lib\site-packages\wfastcgi.py>"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="c:\python37\scripts\python.exe" />
<add key="WSGI_HANDLER" value="manhour_site.wsgi.application" />
<add key="DJANGO_SETTINGS_MODULE" value="manhour_site.settings" />
</appSettings>
</configuration>
After making changes above I am still facing the similar issue hence I looked at this solution.
As per the solution fastCGI settings must be in the applicationHost.config file. This file is located on path C:\Windows\System32\inetsrv\config\applicationHost.config
After following this solution I've made following changes
applicationHost.config
Under <system.webServer> I've added following
<fastCgi>
<application fullPath="c:\python37\scripts\python.exe" arguments="c:\python37\lib\site-packages\wfastcgi.py" maxInstances="4" signalBeforeTerminateSeconds="30">
<environmentVariables>
<environmentVariable name="DJANGO_SETTINGS_MODULE" value="manhour_site.settings" />
<environmentVariable name="PYTHONPATH" value="c:\python37\scripts\python.exe" />
<environmentVariable name="WSGI_HANDLER" value="manhour_site.wsgi.application" />
</environmentVariables>
</application>
</fastCgi>
I've ran the command as administrator wfastcgi-enable.
I need a solution that can point mistake and help in resolving this error.
PS: In my settings.py file I've changed following
DEBUG = 'False'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
Edit
I've added HttpPlatformHandler to web.config
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="fastCGI"
path="*"
verb="*"
modules="FastCgiModule"
scriptProcessor="c:\python37\scripts\python.exe|c:\python37\lib\site-packages\wfastcgi.py"
resourceType="Unspecified"
requireAccess="Script" />
</handlers>
<httpPlatform processPath="c:\python37\scripts\python.exe"
arguments="C:\inetpub\wwwroot\manhour_site\manage.py --port %HTTP_PLATFORM_PORT%"
stdoutLogEnabled="true"
stdoutLogFile="c:\home\LogFiles\python.log"
startupTimeLimit="60"
processesPerApplication="16">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="80" />
</environmentVariables>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="c:\python37\scripts\python.exe" />
<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" />
<add key="DJANGO_SETTINGS_MODULE" value="manhour_site.settings" />
</appSettings>
</configuration>
The above changes causes error The requested page cannot be accessed because the related configuration data for the page is invalid.
Config File \\?\C:\inetpub\wwwroot\web.config