Bitnami Django creating multiple projects

瘦欲@ 提交于 2019-12-22 11:11:12

问题


So I have this Bitnami EC2 instance which had project 'Project' in it by default (at /apps/django/django_projects), so I started following the django tutorial and done everything. I am able to access this project at

http://myIp/Project/.

So after having finished the tutorial I set off to create my own project. I created the project using

django-admin.py startproject DoE

in the same directory as project 'Project' (i.e. /apps/django/django_projects), followed by

python manage.py runserver 0.0.0.0:8000

But the problem is when I go to

http://myIp/DoE/

I get this error:

Not Found

The requested URL /DoE/ was not found on this server.

Any help will be much appreciated. Thanks in advance :)


回答1:


I've found a way to work around this issue, it's a bit hacky but it does the job. I got it from here http://wiki.bitnami.org/Components/Django. But they imply that you only need to do this if you are using an apache webserver which I am not. I am using the django's development server, but nevertheless it works.

Basically I had to create a DoE.conf file in /home/bitnami/apps/django/conf which looks like this:

Alias /static "/opt/bitnami/apps/django/lib/python2.7/site-packages/django/contrib/admin/static"

<Directory '/opt/bitnami/apps/django/lib/python2.7/site-packages/django/contrib'>
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias /DoE "/opt/bitnami/apps/django/scripts/DoE.wsgi"

<Directory '/opt/bitnami/apps/django/scripts'>
Order allow,deny
Allow from all
</Directory>

and then create a file named DoE.wsgi in /home/bitnami/apps/django/scripts which looks like this:

import os, sys
sys.path.append('/opt/bitnami/apps/django/django_projects')
sys.path.append('/opt/bitnami/apps/django/django_projects/DoE')
os.environ['DJANGO_SETTINGS_MODULE'] = 'DoE.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

after that I had to include

/opt/bitnami/apps/django/conf/DoE.conf

in my httpd.conf file, which for my case was here: /opt/bitnami/apache2/conf

After this I restarted my machine/server and all was well :)



来源:https://stackoverflow.com/questions/11659126/bitnami-django-creating-multiple-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!