README
changeset 1 eb9188f2ee4f
equal deleted inserted replaced
0:85b071fb75b2 1:eb9188f2ee4f
       
     1 ==============================
       
     2 Dring 93 - Ubuntu 10.04
       
     3 ==============================
       
     4 
       
     5 1 - Database creation
       
     6 2 - Virtualenv installation
       
     7 3 - Settings
       
     8 4 - Database synchronization
       
     9 5 - .htaccess files
       
    10 6 - WSGI script file
       
    11 
       
    12 
       
    13 1 - Database creation
       
    14 ======================
       
    15 Create a database in Postgres:
       
    16   createdb -U username -W -h 127.0.0.1 d
       
    17 
       
    18 Access to te database in Postgres:
       
    19   psql -U username -W -h 127.0.0.1 dbname
       
    20 
       
    21 \d to view the list of all relations
       
    22 
       
    23 
       
    24 2 - Virtualenv installation
       
    25 ============================
       
    26 Run the bootstrap script generator:
       
    27   python create_python_env.py 
       
    28 
       
    29 Run project-boot.py this way:
       
    30   python hg/dring93/sbin/virtualenv/project-boot.py --no-site-packages --setuptools --unzip-setuptools --type-install=local --ignore-packages=MYSQL path/to/env/Env
       
    31 
       
    32 To activate the environment:
       
    33   source path/to/env/Env/bin/activate
       
    34 
       
    35 
       
    36 
       
    37 3 - Settings
       
    38 =============
       
    39 Enter the db settings in dring93/web/dring93/config.py:
       
    40 DATABASES = {
       
    41     'default': {
       
    42         'ENGINE': 'django.db.backends.postgresql_psycopg2',
       
    43         'NAME': 'dbDring',
       
    44         'USER': 'iriuser', 
       
    45         'PASSWORD': 'iriuser',
       
    46         'HOST': 'localhost',
       
    47         'PORT': '5432',
       
    48     }
       
    49 }
       
    50 
       
    51 Change the URL paths:
       
    52 BASE_URL = '/dev/~user/dring93/'
       
    53 WEB_URL = 'http://www.iri.centrepompidou.fr/'
       
    54 
       
    55 
       
    56 In your public_html, create a symbolic link that points to the application:
       
    57   ln -s path/to/project/dring93 dring93
       
    58 
       
    59 
       
    60 4 - Database synchronization
       
    61 =============================
       
    62 Synchronize the database, in dring93/web/dring93:
       
    63   python manage.py syncdb
       
    64 
       
    65 
       
    66 5 - .htaccess files
       
    67 ====================
       
    68 Write dring93/web/.htaccess:
       
    69 
       
    70 # Permanent redirection to dring93/franculture
       
    71 RedirectMatch permanent /~user/dring93/?$ /~user/dring93/dring93
       
    72 
       
    73 
       
    74 Write dring93/web/dring93/.htaccess:
       
    75 
       
    76 # Set environmental variables used in the wsgi file
       
    77 SetEnv DJANGO_SETTINGS_MODULE dring93.settings
       
    78 SetEnv PY_USE_XMLPLUS true
       
    79 SetEnv PROJECT_PATH /path/to/project/dring93/web
       
    80 SetEnv PYTHON_PATH /path/to/virtual/environment/Env/lib/python2.6/site-packages
       
    81 
       
    82 Options ExecCGI FollowSymLinks
       
    83 SetHandler wsgi-script
       
    84 
       
    85 RewriteEngine On
       
    86 RewriteCond %{REQUEST_FILENAME} !-f
       
    87 RewriteRule ^(.*)$ /path/to/wsgiscript/modwsgi.wsgi/$1 [QSA,PT,L]
       
    88 
       
    89 # html cache options
       
    90 Header set Pragma "no-cache"
       
    91 Header set Cache-Control "no-cache"
       
    92 Header set Expires "-1"
       
    93 
       
    94 
       
    95 
       
    96 6 - WSGI script file
       
    97 ======================
       
    98 
       
    99 Write the WSGI file modwsgi.wsgi
       
   100 
       
   101 import os, sys, site
       
   102 
       
   103 def application(environ, start_response):
       
   104         os.environ['DJANGO_SETTINGS_MODULE'] = environ['DJANGO_SETTINGS_MODULE']
       
   105         os.environ['PY_USE_XMLPLUS'] = environ['PY_USE_XMLPLUS']
       
   106 
       
   107         sys.path.append(environ['PROJECT_PATH'])
       
   108         site.addsitedir(environ['PYTHON_PATH'])
       
   109 
       
   110         import django.core.handlers.wsgi
       
   111         _application = django.core.handlers.wsgi.WSGIHandler()
       
   112 
       
   113         return _application(environ, start_response)
       
   114 
       
   115 
       
   116 Notes:
       
   117 - The 'environ' argument is unrelated to the 'os.environ' argument. It catches the variables that were defined with 'SetEnv' in the .htaccess file.
       
   118 - 'sys.path.append' adds the project path to the PYTHONPATH
       
   119 - 'site.addsitedir' activates the virtual environment