简体   繁体   中英

Apache to serve Django project on EC2 instance — 500 Internal Server Error

I am trying to deploy my Django project on AWS and have Apache serve up my webpages. I am able to deploy the webpages using runserver but I want this to become a production server --thus I want to use Apache. I am receiving a 500 Internal Server error and don't know why.

In my project folder I have a django.wsgi file:

import os
import sys
sys.path.append('home/ubuntu/venv/hde_nate')
os.environ['DJANGO_SETTINGS_MODULE']='web.settings'
import django.core.handlers.wsgi
application=django.core.handlers.wsgi.WSGIHandler()

My /etc/apache2/httpd.conf:

<Directory /home/ubuntu/venv/hde_nate/web>
Order allow, deny
Allow from all
</Directory>

WSGIScriptAlias / /home/ubuntu/venv/hde_nate/web/django.wsgi
alias /static /home/ubuntu/venv/hde_nate/web 

I have a /etc/apache2/mods-enabled/django.conf, but am not sure if this file is necessary:

WSGIScriptAlias / /home/ubuntu/venv/hde_nate/web/django.wsgi
alias /static /home/ubuntu/venv/hde_nate/web

To install apache I used these commands on my linux box:

sudo apt-get install apache2 
sudo apt-get install python-setuptools libapache2-mod-wsgi

settings.py

DEBUG = FALSE
TEMPLATE_DEBUG = FALSE

Edit: My error.log:

[notice] caught SIGTERM, shutting down
[notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations

Solved. Added this to my virtualhost:

WSGIApplicationGroup %{GLOBAL}

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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