On 26 January 2011 07:18, KJQ <[email protected]> wrote: > So, it looks like it is definitely is an issue when I have my PHP > configuration loaded with my WSGI configuration. If I disable the PHP > configuration my WSGI app works fine. If I enable the PHP > configuration I get the "premature" error in the apache log. > > Any suggestions based on my configuration how I would go about setting > up both PHP and WSGI to run within the same apache instance?
Your problem then is going to be one of the following: 1. Some PHP extension is linking in a different/incompatible version of some shared library that a Python C extension module is linking. 2. Some PHP extension module and a Python C extension module are using the same name for a global symbol and so incompatible data is being mixed between the two. All I can suggest you do is to disable extension modules in PHP configuration progressively and by process of elimination work out which PHP extension module clashes and if you aren't using it, then don't load it into PHP. If you can't do that as you need it, then if it is caused by (1), then you need to rebuild either Python or PHP so they use a compatible version of the shared library. If (2), then you are screwed as can only be fixed by changing source code of one or the other to rename variables so they don't use the same name. Graham > Thanks. > > KJQ > > On Jan 25, 1:43 pm, KJQ <[email protected]> wrote: >> Wow. I think I may of found it but would like some validation... >> >> If I strip out PHP from Apache i can get by the issue I posted above. >> >> Any insight on this from anyone? >> >> If this is the case, how can I get this run alongside PHP? >> >> Thanks. >> >> KJQ >> >> On Jan 25, 12:59 pm, KJQ <[email protected]> wrote: >> >> > I can't seem to work through this problem and hopefully, this is the >> > right place to be... >> >> > What has led me to posting this question here is the "premature end of >> > headers" I see in the Apache error log when I try to access a Pyramid >> > application running under WSGI using MongoDB (I did not get before I >> > introduced Mongo and testing direct mongo connections appears to work >> > fine so I do not think it is Mongo yet). >> >> > Once, I introduce mongo (pymongo) and attempt to make a "connection" >> > Apache crashes with the message "Premature end of script headers." If >> > I try this same connection directly (through a Python app on the >> > console) it works fine. If I take out the connection the app appears >> > to work fine then also. >> >> > I've tried created a "test" wsgi script and can mimic the problem my >> > application has. >> >> > Contents below: >> > --------------------------------------------------------------------------------------- >> > - What i have running under Apache using WSGI >> > - Scenarios i've tried: >> > - My Apache configuration >> > - My mod_wsgi output >> > - My "dispatch.wsgi" script >> > - My "test.wsgi" script >> > - Apache error log >> >> > I currently have two applications loaded into Apache under a >> > VirtualHost: >> > --------------------------------------------------------------------------------------- >> > - Django (using buildout and sqllite) >> > - Pyramid (using buildout and mongodb) >> >> > Both, even though they use buildout, are wrapped within a VirtualEnv. >> >> > Scenarios I've tried: >> > --------------------------------------------------------------------------------------- >> > 1) Crashes: Pyramid application using WSGI with MongoDB. >> > 2) Crashes: Direct Connection/query to MongoDB using WSGI (same as >> > #1) >> > 3) Works: DJango application using WSGI >> > 4) Works: Pyramid application using WSGI without MongoDB >> > 5) Works: Direct connection/query to MongoDB using Python >> > 6) Works: Pylons application using WSGI with sqllite >> >> > My Apache configuration: >> > --------------------------------------------------------------------------------------- >> > WSGIPythonEggs /tmp/.python-eggs >> > WSGIRestrictEmbedded On >> > WSGIPassAuthorization On >> > WSGIApplicationGroup %{GLOBAL} >> >> > AddHandler wsgi-script .wsgi >> >> > <VirtualHost 0.0.0.0:80> >> > ServerName apps.test.com >> > DocumentRoot /opt/web/apps.test.com/html >> > SuexecUserGroup XXX YYY >> > ScriptAlias "/cgi-bin/" "/opt/web/apps.test.com/cgi-bin/" >> > CustomLog "/opt/logs/web-access.log" "combined" >> > ErrorLog "/opt/logs/web-dev-error.log" >> > LogLevel DEBUG >> >> > WSGIDaemonProcess wsgi-app1 display-name=wsgi:app1 \ >> > user=XXX \ >> > group=YYY >> >> > WSGIDaemonProcess wsgi-app2 display-name=wsgi:app2 \ >> > user=XXX \ >> > group=YYY \ >> > processes=1 \ >> > threads=4 >> > #### App1: Django >> > WSGIScriptAlias /app1 /opt/wsgi/app1/bin/django.wsgi >> > Alias /app1/static /opt/wsgi/app1-dev/src/web/static >> > Alias /app1/media /opt/wsgi/app1-dev/src/web/media >> > <Directory /opt/wsgi/app1-dev/src/web/static> >> > Order deny,allow >> > Allow from all >> > </Directory> >> > <Directory /opt/wsgi/app1-dev/src/web/media> >> > Order deny,allow >> > Allow from all >> > </Directory> >> > <Directory /opt/wsgi/app1-dev> >> > Options Includes FollowSymLinks >> > Order deny,allow >> > Allow from all >> > AllowOverride All >> > WSGIProcessGroup wsgi-app1 >> > </Directory> >> >> > #### App2: Pyramid >> > WSGIScriptAlias /app2 /opt/wsgi/app2-dev/bin/dispatch.wsgi (or my >> > test one test.wsgi) >> > <Directory /opt/wsgi/app2-dev> >> > Options Includes FollowSymLinks >> > Order allow,deny >> > Allow from all >> > AllowOverride All >> > WSGIProcessGroup wsgi-app2 >> > </Directory> >> > </VirtualHost> >> >> > My mod_wsgi: >> > --------------------------------------------------------------------------------------- >> > # ldd mod_wsgi.so >> > libpython2.7.so.1.0 => /opt/apps/python-2.7/lib/ >> > libpython2.7.so.1.0 (0xb7e13000) >> > libpthread.so.0 => /lib/libpthread.so.0 (0xb7dfc000) >> > libdl.so.2 => /lib/libdl.so.2 (0xb7df8000) >> > libutil.so.1 => /lib/libutil.so.1 (0xb7df4000) >> > libm.so.6 => /lib/libm.so.6 (0xb7dcd000) >> > libc.so.6 => /lib/libc.so.6 (0xb7c88000) >> > /lib/ld-linux.so.2 (0xb7fc1000) >> >> > My 'dispatch.wsgi' script: >> > --------------------------------------------------------------------------------------- >> > #!/opt/wsgi/sprout-dev/env/bin/python >> >> > import sys >> > sys.path[0:0] = [ >> > '/opt/data/buildout/eggs/pyramid-1.0b1-py2.7.egg', >> > '/opt/data/buildout/eggs/WebError-0.10.3-py2.7.egg', >> > '/opt/data/buildout/eggs/PasteScript-1.7.3-py2.7.egg', >> > '/opt/wsgi/sprout-dev/eggs/setuptools-0.6c12dev_r88124-py2.7.egg', >> > '/opt/wsgi/sprout-dev/src', >> > '/opt/data/buildout/eggs/mongoengine-0.4-py2.7.egg', >> > '/opt/data/buildout/eggs/pymongo-1.9-py2.7-linux-i686.egg', >> > '/opt/data/buildout/eggs/WebHelpers-1.2-py2.7.egg', >> > '/opt/data/buildout/eggs/Mako-0.3.6-py2.7.egg', >> > '/opt/data/buildout/eggs/pyramid_zcml-0.1-py2.7.egg', >> > '/opt/data/buildout/eggs/pyramid_handlers-0.1-py2.7.egg', >> > '/opt/data/buildout/eggs/PasteDeploy-1.3.4-py2.7.egg', >> > '/opt/data/buildout/eggs/Paste-1.7.5.1-py2.7.egg', >> > '/opt/data/buildout/eggs/Pygments-1.3.1-py2.7.egg', >> > '/opt/data/buildout/eggs/Tempita-0.5dev-py2.7.egg', >> > '/opt/data/buildout/eggs/WebOb-1.0-py2.7.egg', >> > '/opt/data/buildout/eggs/translationstring-0.3-py2.7.egg', >> > '/opt/data/buildout/eggs/venusian-0.5-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.interface-3.6.1-py2.7-linux- >> > i686.egg', >> > '/opt/data/buildout/eggs/zope.deprecation-3.4.0-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.configuration-3.7.2-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.component-3.10.0-py2.7.egg', >> > '/opt/data/buildout/eggs/repoze.lru-0.3-py2.7.egg', >> > '/opt/data/buildout/eggs/Chameleon-1.2.13-py2.7.egg', >> > '/opt/data/buildout/eggs/MarkupSafe-0.11-py2.7-linux-i686.egg', >> > '/opt/data/buildout/eggs/zope.schema-3.7.0-py2.7.egg', >> >> > from pyramid.paster import get_app >> > application = get_app('/opt/wsgi/sprout-dev/integration.ini', 'main') >> >> > import paste.script.command >> >> > if __name__ == '__main__': >> > paste.script.command.run() >> >> > My 'test.wsgi' script: >> > --------------------------------------------------------------------------------------- >> > #!/opt/wsgi/sprout-dev/env/bin/python >> >> > import sys >> > sys.path[0:0] = [ >> > '/opt/data/buildout/eggs/pyramid-1.0b1-py2.7.egg', >> > '/opt/data/buildout/eggs/WebError-0.10.3-py2.7.egg', >> > '/opt/data/buildout/eggs/PasteScript-1.7.3-py2.7.egg', >> > '/opt/wsgi/sprout-dev/eggs/setuptools-0.6c12dev_r88124-py2.7.egg', >> > '/opt/wsgi/sprout-dev/src', >> > '/opt/data/buildout/eggs/mongoengine-0.4-py2.7.egg', >> > '/opt/data/buildout/eggs/pymongo-1.9-py2.7-linux-i686.egg', >> > '/opt/data/buildout/eggs/WebHelpers-1.2-py2.7.egg', >> > '/opt/data/buildout/eggs/Mako-0.3.6-py2.7.egg', >> > '/opt/data/buildout/eggs/pyramid_zcml-0.1-py2.7.egg', >> > '/opt/data/buildout/eggs/pyramid_handlers-0.1-py2.7.egg', >> > '/opt/data/buildout/eggs/PasteDeploy-1.3.4-py2.7.egg', >> > '/opt/data/buildout/eggs/Paste-1.7.5.1-py2.7.egg', >> > '/opt/data/buildout/eggs/Pygments-1.3.1-py2.7.egg', >> > '/opt/data/buildout/eggs/Tempita-0.5dev-py2.7.egg', >> > '/opt/data/buildout/eggs/WebOb-1.0-py2.7.egg', >> > '/opt/data/buildout/eggs/translationstring-0.3-py2.7.egg', >> > '/opt/data/buildout/eggs/venusian-0.5-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.interface-3.6.1-py2.7-linux- >> > i686.egg', >> > '/opt/data/buildout/eggs/zope.deprecation-3.4.0-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.configuration-3.7.2-py2.7.egg', >> > '/opt/data/buildout/eggs/zope.component-3.10.0-py2.7.egg', >> > '/opt/data/buildout/eggs/repoze.lru-0.3-py2.7.egg', >> > '/opt/data/buildout/eggs/Chameleon-1.2.13-py2.7.egg', >> > '/opt/data/buildout/eggs/MarkupSafe-0.11-py2.7-linux-i686.egg', >> > '/opt/data/buildout/eggs/zope.schema-3.7.0-py2.7.egg', >> >> > import sys >> >> > from mongoengine import * >> >> > class Sample(Document): >> > name = StringField() >> >> > def application(environ, start_response): >> > print('---------------------------------- connecting') >> > connect('sample') >> > print('---------------------------------- connected') >> >> > sample1 = Sample(name = 'aaa') >> > sample2 = Sample(name = 'bbb') >> > sample3 = Sample(name = 'ccc') >> >> > sample1.save() >> > sample2.save() >> > sample3.save() >> >> > for s in Sample.objects: >> > print s.name >> >> > if __name__ == '__main__': >> > application(None, None) >> >> > My Apache error log output: >> > --------------------------------------------------------------------------------------- >> > [Tue Jan 25 12:26:07 2011] [info] mod_wsgi (pid=22279): Attach >> > interpreter ''. >> > [Tue Jan 25 12:26:07 2011] [info] mod_wsgi (pid=22280): Attach >> > interpreter ''. >> > [Tue Jan 25 12:26:11 2011] [info] [client 65.203.93.8] mod_wsgi >> >> ... >> >> read more » > > -- > You received this message because you are subscribed to the Google Groups > "modwsgi" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/modwsgi?hl=en. > > -- You received this message because you are subscribed to the Google Groups "modwsgi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
