我知道类似的内容已得到解答,但我不希望将我的django项目放在我的/ var / www / html目录中,因为它不被视为最佳实践
我的错误日志已阅读
[Sun Aug 06 07:57:16.772735 2017] [mime_magic:error] [pid 13686] [client 37.28.197.227:53652] AH01512:mod_mime_magic:无法读取`/ home / ec2-user / portfolio / portfolio /wsgi.py” [Sun Aug 06 07:57:16.772887 2017] [:error] [pid 13682](13)权限被拒绝:[remote 37.28.197.227:173] mod_wsgi(pid = 13682,process ='d2training',application ='d2training。 com |'):对'/home/ec2-user/portfolio/portfolio/wsgi.py'调用fopen()失败。
我的django.conf看起来像这样
`<VirtualHost *:80>
ServerAdmin dondavis@d2training.com
DocumentRoot /home/ec2-user/portfolio/
ServerName d2training.com
<Directory /home/ec2-user/portfolio/portfolio>
<Files wsgi.py>
Require all granted
</Files>
SetEnvIfNoCase Host d2training VALID_HOST
Require env VALID_HOST
order allow,deny
allow from all
</Directory>
<Directory /home/ec2-user/>
Require all granted
Order allow,deny
Allow from all
</Directory>
<Directory /home/ec2-user/portfolio/media>
Require all granted
Options Indexes
AllowOverride all
Order deny,allow
Allow from all
</Directory>
WSGIDaemonProcess d2training python-path=/home/ec2-user/py3env/:python-home=/home/ec2-user/py3env/lib/python3.4/site-packages
WSGIProcessGroup d2training
WSGIScriptAlias / /home/ec2-user/portfolio/portfolio/wsgi.py
Alias /media/ /home/ec2-user/portfolio/media
ErrorLog /etc/httpd/logs/django.log
CustomLog /etc/httpd/logs/access.log combined
</VirtualHost>`
**我的settings.py文件只是在你需要的时候只提供了大部分文件请告诉我**
`DEBUG = True
ALLOWED_HOSTS = []
'# Application definition'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'd2training',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'portfolio.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'portfolio.wsgi.application'
'# Database'
'# https://docs.djangoproject.com/en/1.11/ref/settings/#databases'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}`
**我的权限是**
截至目前,我已设置/ home /,/ home / ec2-user /,/ home / ec2-user / project,/ home / ec2-user / project / project /,和/ home / ec2-user /project/project/wsgi.py所有到777的访问权限,但它仍然给我500错误。我甚至将用户切换到apache并且能够打开文件,但它仍然给我500错误。到目前为止我在网上找到的几乎所有内容都说它放在/ var / www中或在root中创建一个新目录,但这些选项似乎都不是最佳实践或对我来说似乎是安全的。另外我知道我的整个目录都不应该打开所有内容,但我只是想让它工作,然后限制它们。