The python -c "import django; print(django.get_version())"
test works perfectly so I know django is installed correctly.
I have added the LoadModule line in httpd.conf to load mod_wsgi.so file and the server restarts with no problems.
Update: Running the startup project on the development server works.
I am trying to get through tutorial #1 and get the startupproject demo up and running. As suggested by the tutorial I put my code outside the document root in a folder called www-src
(got a better name?). The DocumentRoot of my wampserver is DocumentRoot "c:/wamp/www/"
.
The file structure is as follows:
|- C:
|- wamp
|- www (DocumentRoot)
|- www-src
|- first_django_site
|- first_django_site
| |- __pycache__
| | |- __init__.cpython-33.pyc
| | |- settings.cpython-33.pyc
| | |- urls.cpython-33.pyc
| | |- wsgi.cpython-33.pyc
| |- __init__.py
| |- settings.py
| |- urls.py
| |- wsgi.py
|- first_django_site.conf
|- manage.py
I want the url to be localhost/first-django-site
in order to separate it from the normal php www projects already in wamp.
What is the way to write paths to access stuff outside the document root? I am not sure if "../" works.
Here are the multiple methods I have tried to write the appropriate apache httpd.conf. What is the best method and correct way to do this?
Block 1:
WSGIScriptAlias /first-django-site "../www-src/first_django_site/first_django_site/wsgi.py"
WSGIPythonPath "../www-src/first_django_site"
<Directory "../www-src/first_django_site/first_django_site">
Order deny,allow
Require all granted
</Directory>
Block 2:
Alias /www-src-alias/ "c:/wamp/www-src/"
<Directory "c:/wamp/www-src/">
Order deny,allow
Require all granted
</Directory>
# alias is way above in the <Ifmodule> so redacted
WSGIScriptAlias /first-django-site "/www-src-alias/first_django_site/first_django_site/wsgi.py"
WSGIPythonPath "/www-src-alias/first_django_site"
<Directory "/www-src-alias/first_django_site/first_django_site">
Order deny,allow
Require all granted
</Directory>
Block 3:
Include "../www-src/first_django_site/first_django_site.conf"
first_django_site.conf
<VirtualHost *:80>
ServerName localhost
#ServerAlias www.mysite.com
WSGIScriptAlias /first-django-site "../www-src/first_django_site/first_django_site/wsgi.py"
WSGIPythonPath "../www-src/first_django_site"
<Directory "../www-src/first_django_site/first_django_site">
Order deny,allow
Require all granted
</Directory>
</VirtualHost>
Block 4: This gives a 500 internal server error.
WSGIScriptAlias /first-django-site "C:/wamp/www-src/first_django_site/first_django_site/wsgi.py"
WSGIPythonPath "C:/wamp/www-src/first_django_site"
<Directory "C:/wamp/www-src/first_django_site/first_django_site">
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
I had assumed I was using the 64 bit version of WAMP but although I am still unsure if I am using 32 or 64 bit WAMP, I have concluded I am using 32 bit.
I used the 32 bit version mod_wsgi.so, restarted the server and it worked.
I used this block of code to run the server (below) and I can access it from: http://localhost/first-django-site
WSGIScriptAlias /first-django-site "C:/wamp/www-src/first_django_site/first_django_site/wsgi.py"
WSGIPythonPath "C:/wamp/www-src/first_django_site/"
<Directory "C:/wamp/www-src/first_django_site/first_django_site/">
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
I have also downloaded the new WampServer 2.4 64 bit and have also successfully set up the django startproject with the mod_wsgi.so 64 bit.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.