how to use fastcgi and virtualenv?
I'm actually answering this question, since I cannot edit the wiki.
1. Setup your virtualenv directory. I'll use /var/admin/graphite as my graphite root dir, and /var/admin/
$ mkdir -p /var/admin/
$ virtualenv /var/admin/
2. activate the environment via: source /var/admin/
# 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-
( 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/
# setup the virtualenv
import os
os.environ.
os.environ['PATH'] = '/var/admin/
os.environ[
os.environ[
os.chdir(
import sys
# Add a custom Python path.
sys.path.insert(0, "/var/admin/
sys.path.insert(0, "/var/admin/
# Switch to the directory of your project. (Optional.)
#os.chdir(
# Set the DJANGO_
os.environ[
from django.
runfastcgi(
6. create an apache virtual host config like this:
NameVirtualHost *:80
FastCgiServer /var/admin/
<VirtualHost *:80>
ServerName graphite.
<Location "/content">
</Location>
ErrorLog /var/admin/
CustomLog /var/admin/
</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
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Graphite Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Allan Bailey
- Solved:
- Last query:
- Last reply: