我在这里错过了什么? Apache保持服务默认页面

时间:2017-02-20 23:08:59

标签: django apache centos mod-wsgi wsgi

我已经配置了我的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()

Settings.py

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

我几乎解决了所有问题。现在我看到的只有403 forbidden error

1 个答案:

答案 0 :(得分:0)

您是否在项目目录中添加了selinux上下文?如果不这样做:

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

restorecon -Rv /home/sbsadmin/myproject/

或尝试停用selinux setenforce 0