Fastcgi Install Instructions
Here are some draft instructions for installing Graphite to run under fastcgi.
1. Setup your virtualenv directory. I'll use /var/admin/graphite as my graphite root dir, and /var/admin/graphite/PYVIRT for my virtualenv environment directory.
$ mkdir -p /var/admin/graphite/PYVIRT
$ virtualenv /var/admin/graphite/PYVIRT
2. activate the environment via: source /var/admin/graphite/PYVIRT/bin/activate
# note, some shells, like zsh, require running 'rehash' so you can find the proper python and easy_install.
3. install needed packages, etc
(PYVIRT)$ easy_install Django
(PYVIRT)$ apt-get install python-cairo python-pyparsing memcached
4. install graphite using --root-dir=/var/admin/graphite, following the standard instructions.
( I used 0.9.4 for this example.)
Note that you'll also need to use 'apt-get install python-mod-python' for the normal install script.
5. create a dispatch.fcgi script like this:
#!/var/admin/graphite/PYVIRT/bin/python
# setup the virtualenv
import os
os.environ.setdefault('PATH', '/bin:/usr/bin')
os.environ['PATH'] = '/var/admin/graphite/PYVIRT/bin:' + os.environ['PATH']
os.environ['VIRTUAL_ENV'] = '/var/admin/graphite/PYVIRT'
os.environ['PYTHON_EGG_CACHE'] = '/var/admin/graphite/PYVIRT/egg_cache'
os.chdir('/var/admin/graphite/webapp')
import sys
# Add a custom Python path.
sys.path.insert(0, "/var/admin/graphite/webapp/web")
sys.path.insert(0, "/var/admin/graphite/webapp")
# Switch to the directory of your project. (Optional.)
#os.chdir("/var/admin/graphite/webapp/web")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
6. create an apache virtual host config like this:
NameVirtualHost *:80
FastCgiServer /var/admin/graphite/dispatch.fcgi -processes 1 -listen-queue-depth 1000 -idle-timeout 3600
<VirtualHost *:80>
ServerName graphite.foxmarks.com
DocumentRoot "/var/admin/graphite/webapp"
ScriptAliasMatch ^(.*)$ /var/admin/graphite/dispatch.fcgi$1
<Location "/content">
SetHandler None
</Location>
ErrorLog /var/admin/graphite/storage/log/webapp-error.log
CustomLog /var/admin/graphite/storage/log/webapp-access.log common
</VirtualHost>
7. fix the carbon init script to source the PYVIRT/bin/activate script so that carbon finds proper libs.
that's it. let me know if you have questions or bugs.
-allan
page revision: 0, last edited: 04 Mar 2009 05:15