Reputation: 117
...
Listen 192.168.20.11:8080
...
LoadModule wsgi_module modules/mod_wsgi.so
...
ServerName 192.168.20.11:8080
...
DocumentRoot "c:/wamp/www/"
...
<VirtualHost *:8080>
ServerName 192.168.20.11
ServerAdmin [email protected]
DocumentRoot "C:/wamp/www/myapp"
<Directory "C:/wamp/www/mapp">
Order allow,deny
Allow from all
</Directory>
Alias /myapp/static "C:/wamp/www/myapp/static"
WSGIScriptAlias /test "C:/wamp/www/myapp/wsgi.py"
</VirtualHost>
Generated by Django's startproject. Located at default /myapp/myapp/wsgi.py
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Cannot deploy Django app on WAMP given the context described above.
A "Hello World" test wsgi application works fine, so I have confirmed that mod_wsgi is active.
I get the error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
when pointing to:
http://192.168.20.11:8080/myapp
The static folder works fine, I can access all static files within the directory by pointing to:
http://192.168.20.11:8080/myapp/static
NB: I've removed the timestamps for legibility.
mod_wsgi (pid=5728, process='', application='192.168.20.11:8080|/myapp'): Loading WSGI script 'C:/wamp/www/myapp/myapp/wsgi.py'.
mod_wsgi (pid=5728): Exception occurred processing WSGI script
'C:/wamp/www/myapp/myapp/wsgi.py'.
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 236, in call
self.load_middleware()
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "C:\Python27\lib\site-packages\django\conf\_init_.py", line 52, in getattr
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\_init_.py", line 47, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\_init_.py", line 132, in init
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" %(self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'myapp.settings' (Is it on sys.path?): No module named myapp.settings
File does not exist: C:/wamp/www/myapp/favicon.ico
I don't understand the function of middleware in this case and was under the impression it wasn't necessary to use middleware.
Regarding the system path, when I add:
WSGIPythonPath "c:/wamp/www/myapp"
to my VirtualHost in the httpd.conf file, the server refuses to start up.
To deploy a working Django app (that has been developed and tested locally using the Django development server) to a Microsoft SBS network without using IIS. I tried deploying on IIS and ran into difficulties early on so switched to WAMP.
I'm new to Python and Django and have never deployed a web app on any production server (I am an R programmer that has generally used programming for math and statistics).
Any advice that would help in achieving this objective, regardless of method, will be much appreciated!
Upvotes: 0
Views: 3947
Reputation: 117
Placing a WSGIPythonPath directive in the httpd.conf prevented the server from starting, but the problem was indeed related to the path not being declared.
Adding:
sys.path.append("c:/wamp/www/myapp")
to the wsgi.py file did the trick.
Thanks to Daniel Roseman for putting me on the right track.
Upvotes: 0
Reputation: 599470
This has nothing to do with middleware, that's just where the error was encountered. The error itself is the last line: "Could not import settings 'myapp.settings'". This is almost certainly because you haven't modified the PYTHONPATH - either in your wsgi or your Apache conf - to put "myapp" on the path.
See for instance the example Apache conf in the Django docs - there's a WSGIPythonPath
directive there to add the app to the Python path, which you don't have.
Upvotes: 1