Here a example how to setup
PyLucid using apache + mod_rewite +
fastCGI .
Note: All guides used the same directory structure .
Checkout the script directory via
subversion :
Bash 1 /home/FooBar$ svn co http://svn.pylucid.net/pylucid/branches/0.9/scripts/
Create the
PyLucid virtual environment:
Bash 1
2 /home/FooBar$ cd scripts
/home/FooBar/scripts$ ./create_test_env.sh
Important: You can't move a created virtual environment into a other directory, after creating them! This is a limitation of virtualenv, see also: make environment relocatable
We create a "page instance" in /var/www/YourSite and use the
PyLucid installation from /home/FooBar/PyLucid_env/ .
Copy
fastCGI dispatcher and .htaccess files:
Bash 1
2 /home/FooBar$ cp scripts/fcgi_scripts/index.fcgi /var/www/YourSite/
/home/FooBar$ cp scripts/fcgi_scripts/default.htaccess /var/www/YourSite/.htaccess
Please edit /var/www/YourSite/.htaccess : In some cases you must activate the suitable AddHandler line.
make .fcgi file executable:
Bash 1 /home/FooBar$ chmod +x /var/www/YourSite/index.fcgi
You must change the path to your created environment in the .fcgi dispatcher file. Edit /var/www/YourSite/index.fcgi and change this part:
Python 1
2
3
4
5
6
7
8
9
10 ...
#####################################################################################################
# CHANGE THIS PATH:
#
# The absolute filesystem path to ...PyLucid_env/bin/activate_this.py
#
os . environ [ "VIRTUALENV_FILE" ] = "/home/FooBar/PyLucid_env/bin/activate_this.py"
#
#####################################################################################################
...
Copy
PyLucid and
django static media files:
Bash 1
2
3
4
5 /home/FooBar$ mkdir -p /var/www/YourSite/media/django/
/home/FooBar$ mkdir -p /var/www/YourSite/media/PyLucid/
/home/FooBar$ cp -r PyLucid_env/src/django/django/contrib/admin/media/* /var/www/YourSite/media/django/
/home/FooBar$ cp -r PyLucid_env/src/pylucid/pylucid_project/media/* /var/www/YourSite/media/
copy 'manage.py' into your page instance:
Bash 1 /home/FooBar$ cp PyLucid_env/scripts/manage.py /var/www/YourSite/
edit the file /var/www/YourSite/manage.py and change the ROOT_DIR to /home/FooBar/PyLucid_env/
To set own settings variable, you should create:
/var/www/YourSite/local_settings.py
You must set this into your local_settings.py:
Python 1
2
3 MEDIA_ROOT = "/var/www/YourSite/media/"
MEDIA_URL = "/media/"
ADMIN_MEDIA_PREFIX = "/media/django/"
Note:
This two path are in default .htaccess in the mod rewrite exception list.
You will get JS errors, if
pylucid media files can't be loaded.
To create all database tables run syncdb:
Bash 1 /var/www/YourSite$ ./manage.py syncdb
Bash 1 .../PyLucidTest/PyLucid_env$ ./manage.sh loaddata pylucid.json
Goto:
Django admin site / Sites / Sites
change the "example.com" to your domain name.
Select from menu these links:
ApacheConf 1
2
3 <VirtualHost YourSite1.tld >
DocumentRoot /var/www/YourSite
</VirtualHost>
A complete example can you found in /scripts/fcgi_scripts/default.htaccess
You must change the path to virtualenv in the line with "VIRTUALENV_FILE".
minimal .htaccess example:
ApacheConf 1
2
3
4 RewriteEngine On
RewriteRule ^media - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.fcgi/$1 [QSA,L]
Python 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 # coding:utf-8
# Absolute _local_filesystem_path_ to the directory that holds media.
MEDIA_ROOT = "/var/www/YourSite/media/"
# URL that handles the media served from MEDIA_ROOT.
# Example-1: "/media/" (default)
# Examlpe-2: "http://other_domain.net/media/"
# Example-3: "http://media.your_domain.net/"
MEDIA_URL = "/media/"
# URL prefix for django admin media -- CSS, JavaScript and images. Saved in /django/contrib/admin/media/
ADMIN_MEDIA_PREFIX = "/media/django/"
SERVE_STATIC_FILES = False # Only needed with developer server
# Changeable if neede:
DEBUG = False
SQL_DEBUG = False
TEMPLATE_DEBUG = False
# Database connection info.
DATABASE_ENGINE = 'sqlite3' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = '' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
SITE_ID = 1
LANGUAGE_CODE = "en"
CACHE_BACKEND = 'file:///tmp/PyLucid_org_cache_ %s ' % SITE_ID