0

I am trying to run django on XAMPP Apache server and followed the steps mentioned here. Here are the changes in Apache config:[![enter image description here][1]][1]

When access the application in browser below is the result instead of django page: [![enter image description here][2]][2]

Please help what I am missing in this ?

@Razenstein: Following are errors in Apache log:

AH02102: C:/xampp/htdocs/polls/mysite/mysite/wsgi.py is not executable; ensure interpreted scripts have "#!" or "'!" first line (9)Bad file descriptor: [client 127.0.0.1:58357] AH01222: don't know how to spawn child process: C:/xampp/htdocs/polls/mysite/mysite/wsgi.py

The application is running fine with built in python server. After correcting Alias getting "500 | Internal Server Error" [1]: https://i.sstatic.net/w2R0Y.png [2]: https://i.sstatic.net/vl8Da.png

5
  • You defined WSGIScriptAlias /mysite " ....." that means only requests to servername/mysite/ are routed to your django app Commented Jan 7, 2022 at 21:48
  • If /mysite is not defined , there was error unable to connect. So when this is defined directory browsing showed up. Commented Jan 8, 2022 at 5:18
  • Yes but the directory listing is a pure Apache response that you get without Apache calling Django. So please do the Alias correctly and post the error message. Please add the Apache error log to your post. Commented Jan 8, 2022 at 5:32
  • I would also recommend during setup to start Apache not via XAMPP but from command line "httpd.exe" because some error messages that you can get during early startup phase of Apache do not appear in error.log and are not showing up in XAMPP window. Once Apache is running correctly with mod_wsgi then we can see if wsgi.py is called and if yes, which error message appears. Is your app running correctly if you start it with "python manage.py runserver"? Commented Jan 8, 2022 at 5:49
  • @Razenstein Thanks for your reply. The post has been updated in light of your comments. Commented Jan 8, 2022 at 12:00

1 Answer 1

1

ok, this error message says that Apache tries to execute wsgi.py as a cgi script and not as python. A possible reason is, that you tried to deploy your app on Apache with some wrong commands that are still in the httpd.conf or vhosts-httpd.conf. This typically happens if you follow one (bad?) tutorial without success, switch to another one and forgot to clean the the code from the first trial (only a guess!). There is all kinds of strange turorials out there and sometimes it is also difficult to understand if they are for Windows or Unix.

Something like the follwing would cause that behavior:

Alias / C:/xampp/htdocs/polls/mysite/mysite/wsgi.py

<Directory C:/xampp/htdocs/polls/mysite/mysite>
    Options +ExecCGI
    AddHandler cgi-script .cgi .pl .asp .py
    Require all granted 
</Directory>

please search in your httpd.conf and vhosts-httpd.conf if you have left something similar.

your "WSGIScriptAlias ...." is overwritten by that and not active.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks @Razenstein for you answer. Yes few days back similar configuration was done and it was still in conf file. There are few changes in wsgi.py file. It is working now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.