mod_wsgi fails to attach requested deamon

42 views
Skip to first unread message

Evgeny

unread,
May 31, 2009, 8:06:58 PM5/31/09
to modwsgi
Hi I'm trying to run web2py as deamon

and in apache error_log I'm getting
[Sun May 31 20:06:09 2009] [info] mod_wsgi (pid=3673): Attach
interpreter ''.

interpreter is httpd, not what I want - and the app fails

Could somebody shed some light on this issue?
Thank you!
Evgeny. (more info is below)

in my httpd.conf i got:
-------------------------------------
User apache
Group apache

<VirtualHost...>

DocumentRoot /var/www/vhosts/default/htdocs/wsgi/web2py
WSGIScriptAlias / /var/www/vhosts/default/htdocs/wsgi/web2py/
WSGIDaemonProcess web2py.py
WSGIProcessGroup web2py
</VirtualHost>

#Below I have

<Directory "/var/www/vhosts/default/htdocs/wsgi/web2py/">
Order allow,deny
Allow from all
WSGIProcessGroup web2py
</Directory>
----------------------------------------
if I type
ls -l /var/www/vhosts/default/htdocs/wsgi/web2py/web2py.py

I get:
-rwxr-xr-x 1 root root 379 May 31 03:02 /var/www/vhosts/default/htdocs/
wsgi/web2py/web2py.py

Graham Dumpleton

unread,
May 31, 2009, 8:42:04 PM5/31/09
to mod...@googlegroups.com
On Jun 1, 10:06 am, Evgeny <evgeny.fad...@gmail.com> wrote:
> Hi I'm trying to run web2py as deamon
>
> and in apache error_log I'm getting
> [Sun May 31 20:06:09 2009] [info] mod_wsgi (pid=3673): Attach
> interpreter ''.

There is nothing wrong with that message, it is an informational
message only and indicates that mod_wsgi has merely done its
initialisation to grab a handle to the Python main interpreter within
that process.

> interpreter is httpd, not what I want - and the app fails
>
> Could somebody shed some light on this issue?
> Thank you!
> Evgeny. (more info is below)
>
> in my httpd.conf i got:
> -------------------------------------
> User apache
> Group apache
>
> <VirtualHost...>
>
> DocumentRoot /var/www/vhosts/default/htdocs/wsgi/web2py

Why have you changed DocumentRoot to that value?

I hope you aren't just copying what the web2py book and web2py people
are telling you. Practically every configuration I have seen from the
web2py people in regard to using web2py with Apache/mod_wsgi has been
wrong in some way. The main example they tell people to use is
actually a bit dangerous and makes your Apache web server less secure
than it could be due to using what would be regarded as being bad
practice. They seem not to have much idea of how to use Apache
properly. However, because they got upset at me at one point and asked
me not to answer questions on the web2py lists, I haven't bothered to
try and correct all the wrong posts on their list.

> WSGIScriptAlias / /var/www/vhosts/default/htdocs/wsgi/web2py/

Why are you aliasing the whole directory? Why aren't you just mounting
the specific script on the root of the web server?

With the way you have it, your URL will need to have the name of the
WSGI script in the URL, ie.,

/web2py.py

Is that way you really want?

From what I have seen, web2py doesn't necessarily always work properly
when it isn't mounted at the root of the web server. At the least you
possibly need to do some manual configuration or fiddles in URL
mapping to get it to work. Seems it may not honour SCRIPT_NAME in WSGI
environment as mount point properly. Whether this is all still true
for latest web2py versions am not sure, but do keep seeing people
having problems with mounting web2py at a sub URL.

> WSGIDaemonProcess web2py.py
> WSGIProcessGroup web2py

Your WSGIProcessGroup argument for name of process group, should match
the name you gave it in WSGIDaemonProcess directive. In your case that
isn't happening. This at least is the absolute minimum change you need
to make if you don't care about the other issues I am raising.

You also shouldn't need the WSGIProcessGroup directive here anyway, as
you have it within the Directory directive container below.

> </VirtualHost>
>
> #Below I have
>
> <Directory "/var/www/vhosts/default/htdocs/wsgi/web2py/">
> Order allow,deny
> Allow from all
> WSGIProcessGroup web2py
> </Directory>

Note that that Directory directive container would still normally be
within the VirtualHost as you likely only want to open up access to
that directory to that VirtualHost and not inadvertently some other
virtual host. Opening it up to all virtual hosts may have security
implications if this is a shared system and specific users virtual
hosts are setup with option to allow Apache to follow symbolic links
when resolving URLs.

> ----------------------------------------
> if I type
> ls -l /var/www/vhosts/default/htdocs/wsgi/web2py/web2py.py
>
> I get:
> -rwxr-xr-x 1 root root 379 May 31 03:02 /var/www/vhosts/default/htdocs/
> wsgi/web2py/web2py.py

Unless you are happy to make the one change to WSGIProcessGroup and
just get on with trying to make it all work regardless, perhaps you
should start over and answer the following questions for me. Then I'll
tell you what you should be using.

1. Where do you want the web2py application mounted, at the root of
the web server, ie., '/', or a sub URL of the site? Is the reason for
aliasing a whole directory because you will have multiple WSGI
applications hosted at different sub URLs?

2. You appear to want to use daemon mode, but do you want to use a
multi threaded or single threaded process?

Once upon a time the default configuration of web2py was such that it
wasn't technically safe to use in a multithreaded process which was
shared with code which wanted to independently fiddle with the current
working directory. This is because web2py used the bad practice of
changing the working directory on each request. A change was
apparently made to it to allow it to use absolute paths and not rely
on changing the working directory, but this was optional and not the
default behaviour. Anyway, not sure what it is you may have to do to
make web2py completely safe to use in a multi threaded process, or
whether proper thread safety is now the default, or the problems
otherwise addressed.

3. What requirements does web2py have for the web server to serve
static files on its behalf? If there are static files the web server
needs to serve up, what URL are they served from and where in the file
system are they located?

Graham

Evgeny

unread,
May 31, 2009, 11:20:09 PM5/31/09
to modwsgi
Hi Graham,

Thank you for your answer. I've tried to do what you've suggested -
that one change - make WSGIDaemonProcess and WSGIProcessGroup match

Now I have in the error log:
(13)Permission denied: mod_wsgi (pid=4456): Unable to connect to WSGI
daemon process 'web2py' on '/etc/httpd/logs/wsgi.4427.0.1.sock' after
multiple attempts

It used to be:
[Sun May 31 22:57:18 2009] [error] [client 128.200.203.33] No WSGI
daemon process called 'web2py' has been configured: /var/www/vhosts/
default/htdocs/wsgi/web2py/applications/admin/controllers/appadmin.py
- when WSGIProcessGroup was not the same as WSGIDaemonProcess.

Does value of WSGIDaemonProcess have to be path (?) to daemon
executable (?) or python script (?) relative to some directory (?)
Or python script has to be in python path?
is .py extension assumed, so process name omits .py ?
- this is something I am confused about.

I do have to run this wsgi in the virtual host, because I use server
for several websites (some use php) so I think can't put wsgi script
at the server root.

Now answers to your three questions:
1) Where do you want the web2py application mounted, at the root of
the web server, ie., '/', or a sub URL of the site? Is the reason for
aliasing a whole directory because you will have multiple WSGI
applications hosted at different sub URLs?

- I don't really have to mount the whole directory - but you're right
- I did so just to be able to try
all the apps that came with web2py - and I wasn't even sure which one
should be in the url...

2) You appear to want to use daemon mode, but do you want to use a
multi threaded or single threaded process?

-at this point I don't care. because I'm just trying to wake it up on
a (remote) apache server.
(I've seen options to WSGIDaemonProcess for threads and processes -
didn't touch them yet)

3) What requirements does web2py have for the web server to serve
static files on its behalf? If there are static files the web server
needs to serve up, what URL are they served from and where in the file
system are they located?

- none at the moment, what if indeed I do have static stuff in some
dir
how can I have that within the same virtual host?
- in fact I would like to eventually be able to have PHP, web2py and
static content
co-exist within the same virtual host.
-would setting WSGIScriptAlias to a concrete resolve the issue?

Kind regards,
Evgeny.



On May 31, 5:42 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:

Graham Dumpleton

unread,
May 31, 2009, 11:30:53 PM5/31/09
to mod...@googlegroups.com
Read:

http://code.google.com/p/modwsgi/wiki/ConfigurationIssues

about permission denied problem.

Haven't had a chance to read rest of email yet, will do so later when have time.

Graham

2009/6/1 Evgeny <evgeny...@gmail.com>:

Evgeny

unread,
Jun 1, 2009, 4:34:21 AM6/1/09
to modwsgi
thanks I got it to work - permissions problem to socket file location,
used WSGISocketPrefix

thanks a lot for the pointer! I'll write up on what I had to do.

Evgeny.

On May 31, 8:30 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> Read:
>
>  http://code.google.com/p/modwsgi/wiki/ConfigurationIssues
>
> about permission denied problem.
>
> Haven't had a chance to read rest of email yet, will do so later when have time.
>
> Graham
>
> 2009/6/1 Evgeny <evgeny.fad...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages