gpt4 book ai didi

django - 我在这里想念什么? Apache 继续提供默认页面

转载 作者:行者123 更新时间:2023-12-04 19:43:49 25 4
gpt4 key购买 nike

我已经配置了我的 Django 站点,但 Apache 继续提供默认的 apache 页面。我在这里想念什么?我的设置是带有 python3.5 的 CentOS 服务器上的 Django 1.10。

项目结构

/home/sbsadmin/web/sbsportal
requirements.txt
src
manage.py
media
sbsportal
__init__.py
__pycache__
settings.py
urls.py
wsgi.py
static
templates
venv

/etc/httpd/conf.d/sbsportal.conf
LoadModule wsgi_module modules/mod_wsgi.so
<VirtualHost *:80>
ServerAdmin admin@email.com
ServerName sbsportal
ServerAlias sbsportal.com
DocumentRoot /home/sbsadmin/web/sbsportal/src/

WSGIDaemonProcess sbsportal python-path=/home/sbsadmin/web/sbsportal/src:/home/sbsadmin/web/sbsportal/venv/lib/python3.5/site-packages
WSGIApplicationGroup sbsportal
WSGIScriptAlias / /home/sbsadmin/web/sbsportal/src/sbsportal/wsgi.py process-group=djangoproj

<Directory /home/sbsadmin/web/sbsportal/src>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Require all granted
</Directory>

<Directory /home/sbsadmin/web/sbsportal/src/sbsportal>
<Files wsgi.py>
Order deny,allow
Allow from all
Require all granted
</Files>
</Directory>

Alias /static /home/sbsadmin/web/sbsportal/src/static
<Directory /home/sbsadmin/web/sbsportal/src/static>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Require all granted
</Directory>

Alias /static /home/sbsadmin/web/sbsportal/src/templates
<Directory /home/sbsadmin/web/sbsportal/src/templates>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Require all granted
</Directory>

Alias /media /home/sbsadmin/web/sbsportal/src/media
<Directory /home/sbsadmin/web/sbsportal/src/media>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride None
Order allow,deny
Require all granted
</Directory>

</VirtualHost>

wsgi.py
"""
WSGI config for sbsportal project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sbsportal.settings")

application = get_wsgi_application()

设置.py
.
.
.
'DIRS': [os.path.join(BASE_DIR, 'templates'),],
.
.
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)

我已经解决了几乎所有的问题。唯一不足的是,现在我看到了 403 forbidden error .

最佳答案

您是否在项目目录中添加了 selinux 上下文?如果没有,请执行以下操作:

semanage fcontext -a -t httpd_sys_content_t '/home/sbsadmin/myproject/(/.*)'

restorecon -Rv /home/sbsadmin/myproject/

或者尝试禁用 selinux setenforce 0

关于django - 我在这里想念什么? Apache 继续提供默认页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42355828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com