刚刚声明主持一个有Django的网站,问题是这样的。
我在/usr/local/django/virenv/Personal/mysite.com/
下放了一个html文件进行测试,000-default.conf
也是from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, a django view.")
中的文档根,该页面可以通过mysite.com访问
然后我在app / view.py中启动了一个django项目和一个应用程序
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^index$', views.index, name = 'index'),
]
在app / urls.py中我放了
urlpattrens = [
url(r'^home/', include('app.urls')),
# below is admin url created with startproject
url(r'^admin/', admin.site.urls)),
]
将以下内容添加到project / urls.py
python manage.py runserver ip:8080
最后我在project / settings.py中将DEBUT = False,并将ip添加到ALLOWED_HOSTS
在404
Not Found The requested URL /admin was not found on this server.
之后,ip:8080 / home / index和ip:8080 / admin都可用。
接下来我尝试重新启动apache2,转到mysite.com/admin和mysite.com/home/index
都得到了
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias / /usr/local/django/virenv/Personal/mysite.com/project/wsgi.py process-group=mysite.com
WSGIPythonHome /usr/local/django/virenv
WSGIDaemonProcess mysite.com python-home=/usr/local/django/virenv python-path=/usr/local/django/virenv/Personal/mysite.com
WSGIProcessGroup mysite.com
WSGIApplicationGroup %{GLOBAL}
<Directory /usr/local/django/virenv/Personal/mysite.com/project>
<Files wsgi.py>
Order allow,deny
Allow from all
Require all granted
</Files>
</Directory>
<Directory /usr/local/django/virenv/Personal/mysite.com/>
Order allow,deny
Allow from all
Require all granted
Options -Indexes +FollowSymLinks -Includes
</Directory>
我猜mod_wsgi无效。
httpd.conf看起来像
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /usr/local/django/virenv/Personal/mysite.com
<Directory /usr/local/django/virenv/Personal/mysite.com>
AllowOverride All
Options +FollowSymLinks
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
000-default.conf看起来像
/usr/local/django/virenv/Personal/mysite.com/*
我使用ubuntu 16 lts和apache2.4,django 1.10
沿着这条路径的每个目录和文件
chmod a+x
设置为chmod a+r
和import os
import sys # added from other stack overflow answers
import django.core.handlers.wsgi as WSGIhand # added from other posts
os.environ.["DJANGO_SETTINGS_MODULE"] = "project.settings"
application = WSGIhand.WSGIHandler()
任何猜测或解决方案?
编辑:顺便说一句,在wsgi.py
GET /sdpjmx/kafkajmx/_search