与Wordpress一起存在的Django Apache mod_wsgi无法建立数据库连接

时间:2017-01-19 11:16:31

标签: django wordpress apache database-connection mod-wsgi

我正在尝试在具有Apache和Wordpress的Centos服务器上部署Django应用程序。 该应用程序正在使用django内置开发服务器没有问题,但当我尝试使用mod_wsgi部署时,我收到一个错误:建立数据库连接时出错。我猜是它与配置文件有关,它试图使用wordpress运行应用程序,而不是mod_wsgi,这就是为什么我得到这个wordpress错误,但我一直在尝试并搜索如何解决这个问题,但我没有解决方案。

我的配置文件是conf.d中的两个单独文件:

django.conf:

Alias /static/ /root/mass_update/static/


<Directory /root/mass_update/static>
Require all granted
</Directory>



WSGIScriptAlias /mass_update /root/mass_update/dashboard/wsgi.py


<Directory /root/mass_update/dashboard>
<Files wsgi.py>
Require all granted
</Directory>

#WSGIPythonPath /var/www/mass_update/:/root/.virtualenvs/dashboard/lib/python2.7/site-packages

WSGIDaemonProcess mass_update  python-path=/root/mass_update:/root/.virtualenvs/dashboard/lib/python2.7/site-packages
WSGIProcessGroup mass_update

idash.conf(WordPress的):

<VirtualHost 172.31.128.20:80>
#       ServerAlias test

        DocumentRoot /var/www/idash
        ServerName idash.test.gr
        <Directory /var/www/idash>
                AllowOverride All
        </Directory>
</VirtualHost>

settings.py:

"""
Django settings for dashboard project.

For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/


# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

TEMPLATE_DEBUG = False

ALLOWED_HOSTS = ['*'] 


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'mass_update',
    'smart_selects',
    'widget_tweaks',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'dashboard.urls'

WSGI_APPLICATION = 'dashboard.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'test',
    'USER': 'test',
    'PASSWORD': 'tes',
    'HOST': 'host_ip',
    'PORT':'host_port',
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_ROOT = 'static/'

STATIC_URL = '/static/'

Django连接到oracleDB。 我也用过&#39; /&#39;作为WSGIScript别名并得到500错误猜测与wordpress在&#39; /&#39;运行时发生冲突 我已尝试对配置文件进行了许多更改,但没有运气。 有没有人有任何建议我错过了什么,可能是什么错误?

谢谢。

1 个答案:

答案 0 :(得分:0)

解决!似乎mysql-community已被删除。并且不得不重新安装它。 安装mysql后一切正常。