Special requirements for Plesk servers

196 views
Skip to first unread message

Seth

unread,
Nov 18, 2008, 5:18:58 AM11/18/08
to modwsgi
Dear group,

I'm trying to set up mod_wsgi with a new TurboGears 2 install inside a
virtualenv. The documentation has been great, except that on Plesk
there is one minor annoyance that requires some special configuration
that I am having trouble with.

Because Plesk overwrites any httpd.conf/httpd.include files you put in
your virtualhosts, you have to use a special 'vhost.conf' file to add
any configuration directives. This special file is included inside the
<VirtualHost /> processing for each domain. That's fine for the
WSGIScriptAlias directive, but others like WSGIPythonHome and
WSGIPythonEggs, etc are not allowed within the VirtualHost section.

How does one configure mod_wsgi for projects within virtualenv, when
the only configuration directives you are permitted are inside of a
VirtualHost section? Are the WSGIPythonHome/etc even required? Can
these directives be done inside the .wsgi file instead (via
site.addsitedir/os.environ)?

Please forgive me if this is basic. I just haven't been able to find
much help that's specific to Plesk.

Thank you,
Seth

Graham Dumpleton

unread,
Nov 18, 2008, 5:43:29 AM11/18/08
to mod...@googlegroups.com
2008/11/18 Seth <seediff...@gmail.com>:

WSGIPythonHome is not required. It does mean though that you will
inherit any Python packages from system wide Python site-packages
directory. If using site.addsitedir() alone in WSGI script file to add
a virtualenv directory, this can be a problem if you are trying to
provide an alternate version of a package to what is in system wide
Python site-packages directory. This is because site.addsitedir() adds
virtualenv directories to end of sys.path and so system wide Python
site-packages will take precedence.

A way around this is instead of using just site.addsitedir() use:

import sys

prev_sys_path = list(sys.path)

import site
site.addsitedir('/some/path/.../site-packages')

# Move the added items to the front of the path:
new_sys_path = []
for item in list(sys.path):
if item not in prev_sys_path:
new_sys_path.append(item)
sys.path.remove(item)
sys.path[:0] = new_sys_path

This will have the affect of moving any directories added by
site.addsitedir() to the head of sys.path instead of at the end. That
way they will take precedence.

This reordering of sys.path is not done with WSGIPythonPath or
WSGIDaemonProcess python-path option in mod_wsgi 2.3, but is done in
mod_wsgi 3.0 code. If using site.addsitedir() you have to do the
reordering yourself as above.

As to WSGIPythonEggs, you can do that yourself in WSGI script file by setting:

import os
os.environ['PYTHON_EGG_CACHE'] = '/some/path/python-eggs'

Graham

Nimrod A. Abing

unread,
Nov 18, 2008, 9:00:35 PM11/18/08
to mod...@googlegroups.com
Put the config customizations in ~<vhostusername>/conf/vhost.conf and
~<vhostusername>/conf/vhost_ssl.conf if you want it set for an
individual virtual hosting account.

In Plesk 7.5.4 and earlier the directory is in:

/home/httpd/vhosts/<domain-name>/conf/

In later versions find them in:

/var/www/vhosts/<domain-name>/conf/

If you're using Plesk + Virtuozzo VPS then you need to take resource
limits into consideration. Search this group's archives since this has
been discussed before.

This is for Plesk
--
Best Regards,
Nimrod A. Abing

W http://arsenic.ph/
W http://preownedcar.com/
W http://preownedbike.com/
W http://abing.gotdns.com/

Seth

unread,
Nov 19, 2008, 1:36:15 PM11/19/08
to modwsgi
Thanks Graham/Nimrod. Everything appears to be working just fine.

Reply all
Reply to author
Forward
0 new messages