Basic Settings for Running Django with Apache and mod-wsgi

Django
2011-06-05 22:39 (13 years ago) ytyng
<div class="document">

<div class="section" id="ubuntu">
<h3>Installing Required Modules (Ubuntu)</h3>
<pre class="literal-block">sudo apt-get install libapache2-mod-wsgi
sudo a2enmod wsgi
</pre>
</div>
<div class="section" id="apache-httpd-conf">
<h3>Apache Configuration File (httpd.conf, etc.)</h3>
<pre class="literal-block">&lt;VirtualHost *:80&gt;
        ServerName   b.ytyng.com
        DocumentRoot /data/htdocs/b.ytyng.com
        ErrorLog     /var/log/apache2/b.ytyng.com/error.log
        CustomLog    /var/log/apache2/b.ytyng.com/access.log combined
        LogLevel warn
        Alias /static /DJANGO-ROOT/static
        Alias /static-admin  /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media
        WSGIScriptAlias   / /DJANGO-ROOT/wsgi/index.wsgi
        WSGIDaemonProcess b.ytyng.com user=www-data group=www-data processes=1 threads=15 home=/ maximum-requests=1000 shutdown-timeout=30
        WSGIProcessGroup  b.ytyng.com
        WSGIPassAuthorization On
&lt;/VirtualHost&gt;
</pre>
</div>
<div class="section" id="index-wsgi">
<h3>index.wsgi</h3>
<pre class="literal-block"># -*- mode: Python; -*-

import os
import sys

path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../'))
if path not in sys.path:
   sys.path.insert(0, path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
</pre>
</div>
</div>
Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011