简体   繁体   English

带有Django 500错误的mod_wsgi

[英]mod_wsgi with Django 500 error

I'm using Ubuntu 14.04, Apache 2.4, Python 2.7.6, Django 1.9.5 and mod_wsgi 4.5.1 installed from source. 我正在使用从源代码安装的Ubuntu 14.04,Apache 2.4,Python 2.7.6,Django 1.9.5和mod_wsgi 4.5.1。

My folder structure looks like so: 我的文件夹结构如下所示:

project
 -site
   -mysite
      -apache
         -wsgi.py

wsgi.py: wsgi.py:

import os, sys

from django.core.wsgi import get_wsgi_application
sys.path.append('/home/me/project/site')
sys.path.append('/home/me/project/site/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'


application = get_wsgi_application()

In my main /etc/apache2/sites-enabled/000-default.conf file I have only edited the following 在我的主要/etc/apache2/sites-enabled/000-default.conf文件中,我仅编辑了以下内容

<VirtualHost *:80>

ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

    WSGIScriptAlias / /home/seb/project/funel/mysite/apache/wsgi.py
            <Directory "/home/seb/project/funel/mysite/apache">
                    Require all granted
            </Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

What am I doing wrong? 我究竟做错了什么? I seem to be getting a 500 Internal Server Error even though restarting Apache doesn't show any problems. 即使重新启动Apache并没有显示任何问题,我似乎也收到500 Internal Server Error。

It sound like your apache configuration is giving you most of the problems. 听起来您的apache配置给您带来了大多数问题。 Please try to write to a log file from within wsgi.py file and determine if the server atleast uses the correct wsgi file. 请尝试从wsgi.py文件中写入日志文件,并确定服务器至少使用了正确的wsgi文件。

For what it is worth I am attaching contents of a_django_site.conf apache config file. 对于值得的是,我附加了a_django_site.conf apache配置文件的内容。 this file should be in /etc/apache2/sites-available and should be enabled using sudo a2ensite a_django_site.conf thereafter reload and restart. 此文件应位于/ etc / apache2 / sites-available中,并应使用sudo a2ensite a_django_site.conf启用,然后重新加载并重新启动。

Define MY_IP=129.222.333.444
WSGIPythonPath  /home/your_name/.virtualenvs/venv_proj_name/bin/python:/home/your_name/.virtualenvs/venv_proj_name/lib/python2.7/site-packages


<VirtualHost *:80>
ServerAdmin root@localhost
ServerName {MY_IP}
ServerAlias http://{MY_IP}/

DocumentRoot /usr/local/src/proj_dir

Alias /static /usr/local/src/proj_dir/django_static/
Alias /images /usr/local/src/proj_dir/stock/media/
Alias /favicon.ico /usr/local/src/proj_dir/apache/favicon.png

WSGIScriptAlias / /usr/local/src/proj_dir/proj_name/wsgi.py

<Directory />
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM