Yo use este manual en Debian, creo que sirve también en derivados, mira si te funciona a ti
===================================================================== Build Websites with Django, Apache and mod_wsgi on Debian 6 (Squeeze) ===================================================================== :Author: Sam Kleinman <mailto:sklein...@linode.com> :Description: Installing and configuring the Django web application development framework for Apache on Debian 6. :Location: http://library.linode.com/frameworks/django-apache-mod-wsgi/debian-6-squeeze :Keywords: django,python,apache,mod_wsgi :License: `CC BY-ND 3.0 <http://creativecommons.org/licenses/by-nd/3.0/us/>`_ :Published: Thursday, February 17th, 2011 :Modified: Friday, May 13th, 2011 by Phil Paradis Django is a web development framework for the Python programing language. It enables rapid development, while favoring pragmatic and clean design. Django was initially developed for use in a newspaper's website division, and as a result the Django framework is very well suited to developing content-centric applications. This guide provides an introduction to getting started with the Django framework, using the ``mod_wsgi`` method of deploying python applications. Please complete the the `getting started guide </getting-started/>`_ prior to beginning this guide on an up to date system. Furthermore, you will want a running `Apache web server </web-servers/apache/installation/debian-6-squeeze>`_ and a functional `MySQL database </databases/mysql/debian-6-squeeze>`_ .. contents:: Contents Set the Hostname ---------------- Before you begin installing and configuring the components described in this guide, please make sure you've followed our instructions for `setting your hostname </getting-started#sph_set-the-hostname>`_. Issue the following commands to make sure it is set properly: :: hostname hostname -f The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN). Install Dependencies -------------------- Issue the following commands to ensure that your system's package repositories and installed programs are up to date and all required software is installed:: apt-get update apt-get upgrade apt-get install python-setuptools libapache2-mod-wsgi Additionally you will need to install a database system and a python driver for this database system. If you want to run the `MySQL database engine </databases/mysql/debian-6-squeeze>`_ issue the following command: :: apt-get install mysql-server python-mysqldb If you want to run the `PostgreSQL database server </databases/postgresql/debian-6-squeeze>`_ issue the following command:: apt-get install postgresql python-psycopg2 If you want to use the SQLite embedded database, issue the following command:: apt-get install sqlite3 python-sqlite Your application may require additional dependencies. You may install these either using the Debian package tools or by using the ``easy_install`` command included in ``python-setuptools``. Install Django -------------- There are two methods for installing Django. You may either choose to install the Django packages from the Debian repositories, or you can install using the python ``easy_install`` method. The version of Django in the package repositories is more stable and benefits from testing and maintenance by Debian developers; however, using ``easy_install`` will always provide access to the latest features. To install Django from the Debian repositories issue the following command:: apt-get install python-django If you want to install Django using the ``easy_install`` tool, issue the following command: :: easy_install Django At the time of writing, this will install version 1.2.5 of the Django framework. Consider the `package information for Django <http://pypi.python.org/pypi/Django>`_ for more information. Configure Django Applications for WSGI -------------------------------------- In order for ``mod_wsgi`` to be able to provide access to your Django application, you will need to create a ``django.wsgi`` file inside of your application directory. For the purposes of this example, we assume that your application will be located *outside* of your ``DocumentRoot`` in the directory ``/srv/www/ducklington.org/application``. Modify this example and all following examples to conform to the actual files and locations used in your deployment. .. file:: /srv/www/ducklington.org/application/django.wsgi :lang: python import os import sys sys.path.append('/srv/www/ducklington.org/application') os.environ['PYTHON_EGG_CACHE'] = '/srv/www/ducklington.org/.python-egg' os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() You must append the path of your application to the system path as above. Additionally, declaration of the ``PYTHON_EGG_CACHE`` variable is optional but may be required for some applications when WSGI scripts are executed with the permissions of the web server. Finally, the ``DJANGO_SETTINGS_MODULE`` must refer to the Django ``settings.py`` file for your project. You will need to restart Apache after modifying the ``django.wsgi`` file. Configure Apache ---------------- Consider the following example virtual host configuration: .. excerpt:: Apache Virtual Host Configuration :lang: apache <VirtualHost *:80> ServerName ducklington.org ServerAlias www.ducklington.org ServerAdmin squ...@ducklington.org DocumentRoot /srv/www/ducklington.org/public_html WSGIScriptAlias / /srv/www/ducklington.org/application/django.wsgi <Directory /srv/www/ducklington.org/application> Order allow,deny Allow from all </Directory> Alias /robots.txt /srv/www/ducklington.org/public_html/robots.txt Alias /favicon.ico /srv/www/ducklington.org/public_html/favicon.ico Alias /images /srv/www/ducklington.org/public_html/images Alias /static /srv/www/ducklington.org/public_html/static ErrorLog /srv/www/ducklington.org/logs/error.log CustomLog /srv/www/ducklington.org/logs/access.log combined </VirtualHost> In this example, the ``WSGIScriptAlias`` directive tells Apache that for this virtual host, all requests below ``/`` should be handled by the WSGI script specified. In the directory block that follows, we allow Apache to serve these requests. Finally, the series of four ``Alias`` directives allow Apache to serve the ``robots.txt`` and ``favicon.ico`` files as well as all resources beneath the ``/images`` and ``/static`` locations, directly from the ``DocumentRoot`` without engaging the WSGI application. You can add as many Alias directives as you need to. When you have successfully configured your Apache virtual host, issue the following commands to disable the default virtual host and restart the web server:: a2dissite default /etc/init.d/apache2 restart You will need to restart the web server every time the ``django.wsgi`` file changes. However, all other modifications to your application do not require a web server restart. Congratulations! You have now successfully deployed a Django application using ``mod_wsgi``. More Information ---------------- .. moreinfo:: - `The Django Project Home Page <http://www.djangoproject.com/>`_ - `The Django Project Introductory Tutorial <http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01>`_ - `The Django Book <http://www.djangobook.com/>`_ - `Deploying Django Applications <http://www.djangobook.com/en/2.0/chapter12/>`_ - `A Basic "Hello World" Django Application <http://appgallery.appspot.com/about_app?app_id=agphcHBnYWxsZXJ5chMLEgxBcHBsaWNhdGlvbnMYvw8M>`_ - `Integrating Django and mod_wsgi <http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango>`_ .. container:: license .. image:: /media/images/cc.png :alt: Creative Commons License This guide is licensed under a `Creative Commons Attribution-NoDerivs 3.0 United States License <http://creativecommons.org/licenses/by-nd/3.0/us/>`_. Last edited by Phil Paradis on Friday, May 13th, 2011 (r1842). Fuente: http://library.linode.com/frameworks/django-apache-mod-wsgi/debian-6-squeeze?format=source El 24 de septiembre de 2011 14:56, Allan N. Porras <alp...@netsescr.com>escribió: > Hola lista! > > He tenido problemas para conectar el django con apache. He leido, y > mod_wsgi (creo q asi se escribre) es el encargado de hacer todo. > > Repito, he estado leyendo guìas pero no comprendo muy bien. > > ¿Algùn humano puede ayudarme y decirme los pasos para poder, DE UNA VEZ POR > TODAS, sacar mi python por el apache? > > Gracias a todos! > > --- > Allan Porras Castillo > Gerente General > Netses Costa Rica S.A > +506 22901016 > _______________________________________________ > Python-es mailing list > Python-es@python.org > http://mail.python.org/mailman/listinfo/python-es > FAQ: http://python-es-faq.wikidot.com/ > -- Diego Alonso Uribe Gamez Twitter: @DiegoUG <http://www.twitter.com/DiegoUG> Google+: http://gplus.to/diegoug ------------------------------ Esta comunicación es confidencial, destinado únicamente para el llamado destinatario (s) anterior y puede contener secretos comerciales u otra información que está exenta de divulgación según la legislación aplicable. Cualquier uso, difusión, distribución o copia de esta comunicación por cualquier persona que no sea el destinatario con nombre (s) está estrictamente prohibido. ------------------------------
_______________________________________________ Python-es mailing list Python-es@python.org http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/