Hosting PHP and Web2py

57 views
Skip to first unread message

vvk

unread,
Jan 19, 2010, 11:12:08 PM1/19/10
to web2py-users
I installed web2py with apache & mod_wsgi. My computer don't have any
Domain Name. Another PHP project should be hosted on same machine. How
to configure my system to run PHP and web2py at the same time?

Temporarily, web2py is using http service and https by PHP site by
modifying httpd.conf file but any permanent solution ?

Graham Dumpleton

unread,
Jan 19, 2010, 11:34:29 PM1/19/10
to web2py-users

What needs to control the root page of the web server, a PHP script or
web2py?

Can the PHP stuff be placed under a common sub URL rather than .php
files sprinkled directly under '/'?

If web2py controls root page and PHP stuff under a common sub URL then
is easy.

If .php is sprinkled in DocumentRoot and should take precedence over
web2py when such files exist, then a little bit tricker to configure,
but still possible.

The information you need is in:

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

so long as you know what to look for and how to apply it. ;-)

BTW, do make absolutely sure web2py running in mod_wsgi daemon mode.
PHP enforces Apache be setup in a particular way which is detrimental
to Python web applications if they are run in embedded mode. Have a
read of:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

Graham

Alexandre Andrade

unread,
Jan 20, 2010, 7:28:32 AM1/20/10
to web...@googlegroups.com
I think is not a good idea.

php requires apache2-prefork (single-thread)
wsgi works with apache2-mpm (multi-thread)

So, they are incompatible.


2010/1/20 vvk <varunk...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/web2py?hl=en.






--
Atenciosamente

--
=========================
Alexandre Andrade
Hipercenter.com

vvk

unread,
Jan 20, 2010, 12:43:49 PM1/20/10
to web2py-users
Our campus servers host many web-sites, so you mean if they run PHP &
apache, web2py may not give good performance ?
Does it mean I need separate server running only apache & web2py
(mod_wsgi) ?


On Jan 20, 5:28 pm, Alexandre Andrade <alexandrema...@gmail.com>
wrote:


> I think is not a good idea.
>
> php requires apache2-prefork (single-thread)
> wsgi works with apache2-mpm (multi-thread)
>
> So, they are incompatible.
>

> 2010/1/20 vvk <varunk.ap...@gmail.com>


>
>
>
>
>
> > I installed web2py with apache & mod_wsgi. My computer don't have any
> > Domain Name. Another PHP project should be hosted on same machine. How
> > to configure my system to run PHP and web2py at the same time?
>
> > Temporarily, web2py is using http service and https by PHP site by
> > modifying httpd.conf file but any permanent solution ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>

mdipierro

unread,
Jan 20, 2010, 12:57:37 PM1/20/10
to web2py-users
This link:

http://markmail.org/message/5cgsibkoohxfh6pl

seems to say that is not a problem (although they experienced other
problems).

Alexandre Andrade

unread,
Jan 20, 2010, 1:18:54 PM1/20/10
to web...@googlegroups.com
This is the best cenario, if you don't want any problems.

Is not because web2py, but because wsgi.

I tried apache mod_proxy, but I have problems too.

I good solution is a virtual server only to apache + web2py.



2010/1/20 vvk <varunk...@gmail.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.



Graham Dumpleton

unread,
Jan 20, 2010, 5:06:57 PM1/20/10
to web2py-users

On Jan 20, 11:28 pm, Alexandre Andrade <alexandrema...@gmail.com>
wrote:


> I think is not a good idea.
>
> php requires apache2-prefork (single-thread)
> wsgi works with apache2-mpm (multi-thread)
>
> So, they are incompatible.

Nonsense.

There is no such thing as apache2-mpm so assume you mean worker MPM.

Even so, Apache/mod_wsgi works with either worker or prefork MPM on
UNIX systems and also works on some of the experimental Apache MPMs as
well.

So, you DO NOT need to use worker MPM to use mod_wsgi.

That said and as explained in:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

If using prefork MPM, you are well advised to run the Python web
application in mod_wsgi daemon mode where you can control both number
of processes and threads for the Python web application.

Also read:

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

where you will find an explanation of the various MPMs of Apache plus
daemon mode and what it means to run a Python web application in each.

That all said, there is one restriction on daemon mode and that is
that it isn't available when using Apache 1.3 and is only available
from Apache 2.0 onwards. This is because Apache 1.3 doesn't use Apache
run time library and all the goodies in it that mod_wsgi uses to
implement daemon mode, plus core functionality of Apache which is
required also isn't present.

Graham

> 2010/1/20 vvk <varunk.ap...@gmail.com>


>
>
>
>
>
> > I installed web2py with apache & mod_wsgi. My computer don't have any
> > Domain Name. Another PHP project should be hosted on same machine. How
> > to configure my system to run PHP and web2py at the same time?
>
> > Temporarily, web2py is using http service and https by PHP site by
> > modifying httpd.conf file but any permanent solution ?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "web2py-users" group.
> > To post to this group, send email to web...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > web2py+un...@googlegroups.com<web2py%2Bunsu...@googlegroups.com>

Alexandre Andrade

unread,
Jan 21, 2010, 8:10:47 AM1/21/10
to web...@googlegroups.com
well, thanks by explanation.

:-)

I think my confusion is because debian/ubuntu, at 'apt-get install libapache2-mod-wsgi', install by default apache2-worker.

I tested installing libapache2-mod-php5 after mod-wsgi,  (e change to apache2-prefork) and web2py still works

The rest is the trick to configure both php and web2py sites. I think a good solution would be virtual hosts:

www.mysite.com - > web2py
other.mysite.com -> php (/var/www)

I will test it later.

2010/1/20 Graham Dumpleton <graham.d...@gmail.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.



Graham Dumpleton

unread,
Jan 22, 2010, 5:20:02 AM1/22/10
to web2py-users
Apache/mod_wsgi can work with prefork, although daemon mode should be
used to avoid problems due to PHP requirement of prefork causing
adverse performance issues of Python web application. See:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

If Ubuntu only has PHP for prefork and only has mod_wsgi for worker
and enforces it, then you will need to compile mod_wsgi from source
code.

Technically same mod_wsgi.so should work for either prefork or worker
MPM, but Ubuntu package manager may not like you mixing it if it has
requirement on mod_wsgi that must have worker MPM.

Anyway, get Apache loading both then not a problem to do it using
separate virtual hosts like you intend.

Graham

On Jan 22, 12:10 am, Alexandre Andrade <alexandrema...@gmail.com>
wrote:


> well, thanks by explanation.
>
> :-)
>
> I think my confusion is because debian/ubuntu, at 'apt-get install
> libapache2-mod-wsgi', install by default apache2-worker.
>
> I tested installing libapache2-mod-php5 after mod-wsgi,  (e change to
> apache2-prefork) and web2py still works
>
> The rest is the trick to configure both php and web2py sites. I think a good
> solution would be virtual hosts:
>

> www.mysite.com- > web2py


> other.mysite.com -> php (/var/www)
>
> I will test it later.
>

> 2010/1/20 Graham Dumpleton <graham.dumple...@gmail.com>


>
>
>
>
>
>
>
> > On Jan 20, 11:28 pm, Alexandre Andrade <alexandrema...@gmail.com>
> > wrote:
> > > I think is not a good idea.
>
> > > php requires apache2-prefork (single-thread)
> > > wsgi works with apache2-mpm (multi-thread)
>
> > > So, they are incompatible.
>
> > Nonsense.
>
> > There is no such thing as apache2-mpm so assume you mean worker MPM.
>
> > Even so, Apache/mod_wsgi works with either worker or prefork MPM on
> > UNIX systems and also works on some of the experimental Apache MPMs as
> > well.
>
> > So, you DO NOT need to use worker MPM to use mod_wsgi.
>
> > That said and as explained in:
>

> >http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usa...

> > <web2py%2Bunsu...@googlegroups.com<web2py%252Bunsubscribe@googlegroups. com>

Alexandre Andrade

unread,
Jan 22, 2010, 7:18:11 AM1/22/10
to web...@googlegroups.com
Ubuntu defines apache2-worker when installing mod-wsgi, but don't uninstall when you change to prefork.

So you can use the setup_web2py.sh script in ubuntu and after install php.




2010/1/22 Graham Dumpleton <graham.d...@gmail.com>
To unsubscribe from this group, send email to web2py+un...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/web2py?hl=en.

Reply all
Reply to author
Forward
0 new messages