New install; problem with daemon mode

69 views
Skip to first unread message

Brian Neal

unread,
Jan 8, 2009, 10:59:06 PM1/8/09
to modwsgi
Hi -

I have a Fedora Core 6 server and I'm trying to use mod_wsgi for the
first time. I've gotten pretty far, I'm just having trouble getting
daemon mode to work.

I am already running mod_python for one virtual host (which I hope to
eventually replace with mod_wsgi).

First of all, I had to create a symlink to the python shared library
in my python2.4/config directory before the mod_wsgi.so file would use
it. After making and make install I used the ldd command to verify
that it had a dependency on the shared library version of python.

I added the LoadModule line to my apache conf file and got apache up
and running after doing a start and stop.

Following along in the Quick Configuration guide, I got a test.py file
containing the simple WSGI application created.

I already have a site running wordpress on one of my virtual hosts at
the root. As a test, I wanted to run the test.py file at mysite.com/
test. So I added the following lines to my configuration (inside my
existing VirtualHost container):

WSGIScriptAlias /test /var/local/wsgi-scripts/test.py
<Directory /var/local/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>

/var/local/wsgi-scripts is where I put my test.py file.

I restarted apache, and visited mysite.com/test and received the
expected output. Cool!

So then the next step was to try the daemon mode. I added 2 more
directives so it looks like this now:

WSGIDaemonProcess mysite.com processes=2 threads=15 display-name=%
{GROUP}
WSGIProcessGroup mysite.com
WSGIScriptAlias /test /var/local/wsgi-scripts/test.py
<Directory /var/local/wsgi-scripts>
Order allow,deny
Allow from all
</Directory>

I restarted apache. When I now visit mysite.com/test the browser seems
to hang. Eventually it just comes back with a white page.

I'm fairly green with this stuff. Any advice to troubleshoot this?
Thanks!

Graham Dumpleton

unread,
Jan 9, 2009, 5:30:10 AM1/9/09
to mod...@googlegroups.com
2009/1/9 Brian Neal <bgn...@gmail.com>:
>
> Hi -
>
> I have a Fedora Core 6 server and I'm trying to use mod_wsgi for the
> first time. I've gotten pretty far, I'm just having trouble getting
> daemon mode to work.
>
> I am already running mod_python for one virtual host (which I hope to
> eventually replace with mod_wsgi).

If you are still loading mod_python, it was likely not linked against
shared Python library. That mod_wsgi then is will then cause a
conflict which could result in many strange things happening. Either
disable mod_python or rebuild mod_python from source code so it also
uses shared Python library now that you have fixed up symlink issue in
config directory for Python. Remember to completely stop Apache when
swapping over mod_python module.

Try that and then we will look further if issues.

Graham

Brian Neal

unread,
Jan 9, 2009, 7:43:32 PM1/9/09
to modwsgi
On Jan 9, 4:30 am, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2009/1/9 Brian Neal <bgn...@gmail.com>:
>
>
>
> > Hi -
>
> > I have a Fedora Core 6 server and I'm trying to use mod_wsgi for the
> > first time. I've gotten pretty far, I'm just having trouble getting
> > daemon mode to work.
>
> > I am already running mod_python for one virtual host (which I hope to
> > eventually replace with mod_wsgi).
>
> If you are still loading mod_python, it was likely not linked against
> shared Python library.  That mod_wsgi then is will then cause a
> conflict which could result in many strange things happening. Either
> disable mod_python or rebuild mod_python from source code so it also
> uses shared Python library now that you have fixed up symlink issue in
> config directory for Python. Remember to completely stop Apache when
> swapping over mod_python module.
>
> Try that and then we will look further if issues.
>
> Graham

Hi Graham -

I commented out the configuration of my one vhost running mod_python,
but I still get the same behavior when trying to run mod_wsgi in
daemon mode. I request the URL, the browser just spins for a while,
then eventually a white page. Nothing is appearing in the error logs
with my current error levels.

Thanks,
BN

Graham Dumpleton

unread,
Jan 9, 2009, 7:49:18 PM1/9/09
to mod...@googlegroups.com
2009/1/10 Brian Neal <bgn...@gmail.com>:

You have to also comment out the LoadModule line for mod_python, with
full stop/stop of Apache after that.

This may well not be the issue, but mixing mod_python and mod_wsgi
where they don't both link to the Python shared library is a know
source of crashes. So, rather eliminate this as issue first. We can
then look at what application you are running and what third party
modules for database etc you are using.

BTW, does the Apache instance also load PHP module?

Graham

Brian Neal

unread,
Jan 9, 2009, 8:17:20 PM1/9/09
to modwsgi


On Jan 9, 6:49 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
Hi -

This is strange. I did indeed forget about the LoadModule line for
mod_python. I commented that out, and when I tried to restart apache I
just got a slew of child segmentation faults:

[Fri Jan 09 19:08:37 2009] [notice] child pid 11332 exit signal
Segmentation fault (11)
[Fri Jan 09 19:08:37 2009] [alert] mod_wsgi (pid=11333): Unable to
determine home directory for uid=xxx

>
> BTW, does the Apache instance also load PHP module?

Yes. I am also using MySQL with PHP and I installed the MySQL python
bindings a while back (they are probably using the static python
library). I'm also running SVN.

Thanks!

Graham Dumpleton

unread,
Jan 9, 2009, 9:04:22 PM1/9/09
to mod...@googlegroups.com

What command did you use to stop/start Apache?

This looks like you did not do a full stop and then a start, but just
a reload or restart. In other words, it didn't actually shutdown the
parent Apache process completely, but just told it to try and reload
stuff within same process.

>> BTW, does the Apache instance also load PHP module?
>
> Yes. I am also using MySQL with PHP and I installed the MySQL python
> bindings a while back (they are probably using the static python
> library). I'm also running SVN.

Use of PHP in same Apache can also cause issues, but in general if it
is going to cause a problem it will do it in embedded mode as well as
daemon mode.

Still not happy at this point that Apache was completely stopped, so
double check that it was and post commands you are using to do it.

Graham

Brian Neal

unread,
Jan 9, 2009, 9:58:09 PM1/9/09
to modwsgi
On Jan 9, 8:04 pm, Graham Dumpleton <graham.dumple...@gmail.com>
Hi,

I am pretty sure I used this sequence to start/stop Apache:

# apachectl stop
# apachectl start

I will try again shortly and confirm.

Thanks again.

Graham Dumpleton

unread,
Jan 9, 2009, 10:07:33 PM1/9/09
to mod...@googlegroups.com
2009/1/10 Brian Neal <bgn...@gmail.com>:

> This is strange. I did indeed forget about the LoadModule line for
> mod_python. I commented that out, and when I tried to restart apache I
> just got a slew of child segmentation faults:
>
> [Fri Jan 09 19:08:37 2009] [notice] child pid 11332 exit signal
> Segmentation fault (11)
> [Fri Jan 09 19:08:37 2009] [alert] mod_wsgi (pid=11333): Unable to
> determine home directory for uid=xxx

Can you ensure you have set:

LogLevel info

instead of default of:

LogLevel warn

that Apache generally uses.

Then look at the Apache error logs and see if you can confirm whether
the processes that are crashing are the mod_wsgi daemon processes. If
you can post an example of messages from logs for same pid that shows
where in mod_wsgi initialisation of daemon process it got, that would
help.

Also, do you have SELinux extensions enabled for the operating system?

These have been known to cause daemon mode processes to crash on
startup or otherwise not work before.

Graham

Brian Neal

unread,
Jan 10, 2009, 1:58:15 PM1/10/09
to modwsgi
Graham,

I turned LogLevel to info and tried again. I don't know if I have any
SELinux extensions. I think it is just Fedora Core 6 running with
Plesk.

Here is part of my log after I stop and start apache.

http://dpaste.com/107543/

Looks like I am running fcgi also, although I don't believe I am using
it for anything. I also removed some warnings about my SSL certificate
being messed up. I didn't think it was relevant and it had site
details in it I didn't want to share.

Thanks again.

BN

PS I have Ubuntu installed on a laptop, and I think I'll try to get
mod_wsgi running over there. I may just want to re-image my production
server to something newer than Fedora Core 6 anyway.


Graham Dumpleton

unread,
Jan 10, 2009, 5:52:44 PM1/10/09
to mod...@googlegroups.com
2009/1/11 Brian Neal <bgn...@gmail.com>:

It is possible you are encountering the following issue:

http://code.google.com/p/modwsgi/issues/detail?id=40

If User/Group directives in Apache configuration files don't proceed
WSGIDaemonProcess and you haven't set user/group for
WSGIDaemonProcess, it will crash when starting up daemon process. Was
thinking whether this was issue before, but wanted to eliminate
mod_python as cause first.

So, are the User/Group directives set in Apache configuration and if
so to what? Are those directives set before WSGIDaemonProcess would be
read as part of configuration?

Does the problem go away if you supply user and group options to
WSGIDaemonProcess where the user and group is set to what is
appropriate for your own account?

WSGIDaemonProcess mysite.com processes=2 threads=15 user=yourusername
group=yourdefaultgroup display-name=%{GROUP}

Graham

Brian Neal

unread,
Jan 10, 2009, 6:51:43 PM1/10/09
to modwsgi
On Jan 10, 4:52 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
>
> It is possible you are encountering the following issue:
>
> http://code.google.com/p/modwsgi/issues/detail?id=40
>
> If User/Group directives in Apache configuration files don't proceed
> WSGIDaemonProcess and you haven't set user/group for
> WSGIDaemonProcess, it will crash when starting up daemon process. Was
> thinking whether this was issue before, but wanted to eliminate
> mod_python as cause first.
>
> So, are the User/Group directives set in Apache configuration and if
> so to what? Are those directives set before WSGIDaemonProcess would be
> read as part of configuration?

The User/Group directives are not set in the Apache configuration
currently.

>
> Does the problem go away if you supply user and group options to
> WSGIDaemonProcess where the user and group is set to what is
> appropriate for your own account?
>
> WSGIDaemonProcess mysite.com processes=2 threads=15 user=yourusername
> group=yourdefaultgroup display-name=%{GROUP}
>

Yes! The problem does go away when I add user=xxx and group=yyy to the
WSGIDaemonProcess directive.

I do still have to disable mod_python to get this to work however (but
that is my long term plan anyway :-) ). If mod_python is still
installed my site just hangs when it requests the URL that mod_wsgi is
supposed to serve in daemon mode (but not embedded).

So thank you very much Graham for your help! And also, thank you very
much for the very detailed documentation you have. I never would have
attempted this without having such thorough docs to guide me and
actually explain what each step was doing.

Cheers,
BN

Graham Dumpleton

unread,
Jan 10, 2009, 7:04:25 PM1/10/09
to mod...@googlegroups.com
2009/1/11 Brian Neal <bgn...@gmail.com>

>
> On Jan 10, 4:52 pm, Graham Dumpleton <graham.dumple...@gmail.com>
> wrote:
> >
> > It is possible you are encountering the following issue:
> >
> > http://code.google.com/p/modwsgi/issues/detail?id=40
> >
> > If User/Group directives in Apache configuration files don't proceed
> > WSGIDaemonProcess and you haven't set user/group for
> > WSGIDaemonProcess, it will crash when starting up daemon process. Was
> > thinking whether this was issue before, but wanted to eliminate
> > mod_python as cause first.
> >
> > So, are the User/Group directives set in Apache configuration and if
> > so to what? Are those directives set before WSGIDaemonProcess would be
> > read as part of configuration?
>
> The User/Group directives are not set in the Apache configuration
> currently.

My understanding is that they should always be set as there is no
guarantee that the defaults of -1/-1 for each would match to a valid
user in the passwd/groups file of a particular operating system. If
the Apache is a binary distribution from Fedora and they have
commented these out in default configuration, that is most odd.

Is Apache a binary distribution or self built from source code and you
had commented out User/Group yourself?

Graham

Brian Neal

unread,
Jan 10, 2009, 7:14:39 PM1/10/09
to modwsgi
On Jan 10, 6:04 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2009/1/11 Brian Neal <bgn...@gmail.com>
>
> > The User/Group directives are not set in the Apache configuration
> > currently.
>
> My understanding is that they should always be set as there is no
> guarantee that the defaults of -1/-1 for each would match to a valid
> user in the passwd/groups file of a particular operating system. If
> the Apache is a binary distribution from Fedora and they have
> commented these out in default configuration, that is most odd.
>
> Is Apache a binary distribution or self built from source code and you
> had commented out User/Group yourself?
>
> Graham

I'm sorry, I was mistaken. There are User and Group directives in the
main httpd.conf file, they are currently set to apache.

The server I am renting comes with a Fedora Core 6 distro and a Plesk
web-based control panel that actually does the generating of the
complex apache and virtual host configuration files. I did not setup
apache. You click around in Plesk to create domains, sub-domains,
etc., and Plesk generates the apache config files.

So it does seem odd that the WSGI daemon processes didn't pick up
apache user and group settings.

Regards,
BN

Graham Dumpleton

unread,
Jan 10, 2009, 7:17:40 PM1/10/09
to mod...@googlegroups.com
2009/1/11 Brian Neal <bgn...@gmail.com>:

The way the web host has set up order of inclusions, if using config
snippets, is probably then that the User/Group are not set early
enough and WSGI stuff is getting processed before they have been set.
User/Group is really one of those things that should be set early on,
as modules could rely on what the values have been set to, but then
modules could also delay looking up values until after configuration
phase. The latter is what mod_wsgi really needs to do, but haven't got
around to it.

Graham

Brian Neal

unread,
Jan 10, 2009, 7:26:01 PM1/10/09
to modwsgi
On Jan 10, 6:17 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

> The way the web host has set up order of inclusions, if using config
> snippets, is probably then that the User/Group are not set early
> enough and WSGI stuff is getting processed before they have been set.
> User/Group is really one of those things that should be set early on,
> as modules could rely on what the values have been set to, but then
> modules could also delay looking up values until after configuration
> phase. The latter is what mod_wsgi really needs to do, but haven't got
> around to it.
>
> Graham

Graham, you are exactly right. Here is a snippet from my main
http.conf file:

Include conf.d/*.conf
# whole bunch of comment lines go here
User apache
Group apache

I have a directory called conf.d which has many *.conf files: one for
python, one for subversion, perl, etc., and I added one for mod_wsgi.
So it does look like User and Group are set after reading those sub-
conf files.

Thanks again,
BN
Reply all
Reply to author
Forward
0 new messages