汇出Django的创建多个项目多个、项目、Django

2023-09-11 09:02:15 作者:y个人、也能活

所以我有这个汇出EC2实例这在它有工程项目在默认情况下(在/应用程序/ Django的/ django_projects),所以我开始关注Django的教程和所做的一切。我能够访问此项目,

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

在同一个目录中的项目'项目'(即/应用/ Django的/ django_projects),然后按

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.

任何帮助将大大AP preciated。在此先感谢:)

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

推荐答案

我已经找到一种方法来解决这个问题,这是一个有点哈克,但它的工作。 我从这里 http://wiki.bitnami.org/Components/Django 得到它。 但他们暗示,你只需要,如果你使用的是Apache网络服务器,我不是来做到这一点。我现在用的是Django的开发服务器,但尽管如此,它的工作原理。

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.

基本上,我必须创建在/ home /汇出/应用程序/ Django的/ conf目录一DoE.conf文件,该文件是这样的:

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>

然后创建一个名为DoE.wsgi在/ home /汇出/应用程序/ Django的/脚本,它看起来像这样的文件:

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

在我的httpd.conf文件中,在我的情况下,在这里中:/ opt /汇出/ apache2的/ 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 :)