Update 2011-06-01: Still not working perfectly, but I did manage to clean up a couple steps by using more of mod_wsgi’s bells and whistles:
- Using a .pth file and the WSGIPythonPath directive you don’t need to manually load all the eggs into sys.path
- Using Daemon Mode per Graham Dumpleton’s comment. To be honest I haven’t noticed any difference caused by this change…
Issues:
- The site is still slow (despite using Daemon Mode)
- I get signal errors. This is a known problem when trying to serve signal-dependent python stuff via mod_wsgi, but I’m not sure it causes any real problems.
[Wed Jun 01 17:59:40 2011] [warn] mod_wsgi (pid=12739): Callback registration for signal 10 ignored. [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/zeocluster/zope2.wsgi", line 3, in [Wed Jun 01 17:59:40 2011] [warn] application = make_wsgi_app(None, '/var/www/Plone-ZEO-4.1rc2/zeocluster/parts/client1/etc/zope.conf') [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/Zope2-2.13.7-py2.6.egg/Zope2/Startup/run.py", line 68, in make_wsgi_app [Wed Jun 01 17:59:40 2011] [warn] starter.prepare() [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/Zope2-2.13.7-py2.6.egg/Zope2/Startup/__init__.py", line 90, in prepare [Wed Jun 01 17:59:40 2011] [warn] self.registerSignals() [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/Zope2-2.13.7-py2.6.egg/Zope2/Startup/__init__.py", line 340, in registerSignals [Wed Jun 01 17:59:40 2011] [warn] self.cfg.trace]) [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/Zope2-2.13.7-py2.6.egg/Signals/Signals.py", line 115, in registerZopeSignals [Wed Jun 01 17:59:40 2011] [warn] SignalHandler.registerHandler(SIGUSR1, showStacks) [Wed Jun 01 17:59:40 2011] [warn] File "/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/Zope2-2.13.7-py2.6.egg/Signals/SignalHandler.py", line 37, in registerHandler [Wed Jun 01 17:59:40 2011] [warn] signal.signal(signum, self.signalHandler)
- In many cases I can’t POST to the site. I can log in as long as it’s not HTTP Basic, but I can’t edit pages or make site-setup configuration changes. Not sure why.
Notes:
- For the following instructions I did every step as the user apache, so Plone runs as that user, as does zeo. This may not be the absolute best practice, but it made things a bit simpler.
- You can substitute instance in probably every case I used client1.
- Install Apache and mod_wsgi. Make sure to specify Python 2.6 for mod_wsgi.
- Grab a Plone 4.1 release candidate and install it as the user apache. Use the same Python 2.6 as you did for mod_wsgi.
- Create a path configuration file:
$ ( # Do this in a subshell so we don't contaminate the IFS > # variable in our normal shell. > cd /var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs > eggs=( *.egg ) > IFS=$'\n' > echo "${eggs[*]}" > mod_wsgi.pth > ) - In your buildout directory create an empty file called ‘zope2.wsgi.in’ as a collective.recipe.template template.
copy the bin/client1 file into zope2.wsgi.in (because you need all the egg paths) - Put these two lines in it:
from Zope2.Startup.run import make_wsgi_app application = make_wsgi_app(None, '${zope-conf}') - Add a section called wsgi to your buildout.cfg file:
[buildout] … parts = … wsgi … … [wsgi] recipe = collective.recipe.template input = zope2.wsgi.in output = zope2.wsgi zope-conf = ${client1:location}/etc/zope.conf - In your apache config:
… WSGIPythonPath /var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/ WSGIDaemonProcess neon processes=1 threads=1 python-path=/var/www/Plone-ZEO-4.1rc2/buildout-cache/eggs/ WSGIProcessGroup neon WSGIScriptAlias / /var/www/Plone-ZEO-4.1rc2/zeocluster/zope2.wsgi <Directory "/var/www/Plone-ZEO-4.1rc2/zeocluster"> Order allow,deny Allow from all </Directory> … - Run buildout and start the zeoserver.
- I had some problems with HTTP Basic Authentication through WSGI, so I avoided it by starting the client without WSGI for the purpose of logging in to the ZMI to create the Plone site.
bin/client1 fg - Log in to http://localhost:8080 and create the Plone site.
- Once I had actually created the Plone site, I killed the client1 instance and removed the <http-server> section from zope.conf
- Start apache, and observe the logs as you navigate around your Plone site on port 80.
As I said, my site is slow and a lot of errors appear in the logs, but it’s functional, which is better than I’ve seen it so far. More work on this later.
Use mod_wsgi daemon mode, then you can run it as a non Apache user. Will possibly solve your slow problem as running in embedded mode bad for very fat application. Have a read of:
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide#Delegation_To_Daemon_Process
http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html
Perhaps you can do without the zope.wsgi.in step by taking the paste.ini example from http://nathanvangheem.com/news/running-plone-4-with-a-zope2-wsgi and creating the zope2.wsgi script with http://pypi.python.org/pypi/collective.recipe.modwsgi.
You might not be able to POST as you only have 1 process and 1 thread. If the UI is dependent on sending concurrent AJAX requests such that a subsequent request needs to finish before a prior request will return then it may be locking up as subsequent AJAX request will be queued up behind the first. As Plone allows, use either multiple processes and/or threads and see how it goes.