You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by howard chen <ho...@gmail.com> on 2008/06/03 18:11:37 UTC

[users@httpd] Difference in mod_perl & mod_php

I mean the theory behind.

People saying that mod_perl is closer to the Apache core,
as it can be used to write Apache module, but in fact, what are their
difference in term of processing model?

Howard

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
> On Wed, Jun 4, 2008 at 1:16 AM, Joshua Slive <jo...@slive.ca> wrote:
> > On Tue, Jun 3, 2008 at 1:09 PM, howard chen <ho...@gmail.com> wrote:
> >
> > Yes, if by "embedded" you mean "running in the same process/thread
> > space with direct access to the apache API".

On 04.06.08 01:23, howard chen wrote:
> The difference is, say using mod_perl, modules are long live as long
> as Apache is running and global variables can be shared across request
> from different clients.
> 
> If you changed the Perl module (pm), restart of server is needed.
> 
> While php don't have this issue. Each request is completely isolated.
> 
> So this is why I am asking the difference between mod_perl & mod_php
> in term of Apache processing, what are the difference.

I already explained the difference. Read my explanation again and forget
what you have been thinking about it before. It only confuses you.
Forget about "being close", forget about "processing model". 

mod_php reads and interprets PHP scripts stored in www root and sends their
output to user.


mod_perl loads scripts defined in configuration file and parses them when
apache is started. With such modules you can do logging (like mod_log_*),
rewriting requests (like mod_rewrite) or configure apache to configure
virtual hosts from SQL instead of configuration file.

mod_perl does NOT interpret perl files stored in WWW root. However, with
mod_perl, you can create a module that would interpret files stored in WWW
root.

mod_perl is something like using perl scripts instead of compiled binary
code for whatever.


-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
10 GOTO 10 : REM (C) Bill Gates 1998, All Rights Reserved!

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
> From: "howard chen" <ho...@gmail.com>
> >On Wed, Jun 4, 2008 at 1:16 AM, Joshua Slive <jo...@slive.ca> wrote:
> >>On Tue, Jun 3, 2008 at 1:09 PM, howard chen <ho...@gmail.com> wrote:
> >>
> >>Yes, if by "embedded" you mean "running in the same process/thread
> >>space with direct access to the apache API".
> >>
> >>Joshua.
> >
> >The difference is, say using mod_perl, modules are long live as long
> >as Apache is running and global variables can be shared across request
> >from different clients.

On 03.06.08 21:31, Octavian Rasnita wrote:
> Yes, and for this reason, in a mod_perl program you could create a 
> permanent connection to the database and each time you make another query, 
> you don't need to establish a new connection, and this means that it will 
> work faster.

mod_php supports permanent connections to databases too. At least to mysql.

The biggest problem with mod_perl is that people tent to compare it with
mod_php. They could compare it with mod_rewrite, mod_log_common, or mod_proxy
with similar results (differences).

mod_perl can do (nearly) anything what any modules can do. It will be just
done by perl interpreter, instead of interpreting binary code compiled from
C (as most apache modules are) by CPU itself.

-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Boost your system's speed by 500% - DEL C:\WINDOWS\*.*

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Octavian Rasnita <or...@gmail.com>.
From: "howard chen" <ho...@gmail.com>
> On Wed, Jun 4, 2008 at 1:16 AM, Joshua Slive <jo...@slive.ca> wrote:
>> On Tue, Jun 3, 2008 at 1:09 PM, howard chen <ho...@gmail.com> wrote:
>>
>> Yes, if by "embedded" you mean "running in the same process/thread
>> space with direct access to the apache API".
>>
>> Joshua.
>
> The difference is, say using mod_perl, modules are long live as long
> as Apache is running and global variables can be shared across request
> from different clients.

Yes, and for this reason, in a mod_perl program you could create a permanent 
connection to the database and each time you make another query, you don't 
need to establish a new connection, and this means that it will work faster.
And sometimes you might want to share global variables between different 
requests.

Of course, if you don't want that and if your program is done right, they 
won't be shared.

> If you changed the Perl module (pm), restart of server is needed.

Not necessarily. You could configure Apache (in httpd.conf) so if you modify 
a perl module, Apache will reload the new code.

> While php don't have this issue. Each request is completely isolated.

In a mod_perl program this is an issue if the program has errors in it, 
otherwise not.

> So this is why I am asking the difference between mod_perl & mod_php
> in term of Apache processing, what are the difference.

When a client makes an HTTP request to an Apache server then the server 
sends a response, there are 7 phases (if I remember well) that should be 
completed.

Only one of these phases is the response phase, which gets the URL 
requested, do something with it (gets the variables from query string, from 
the path, port...) and creates the response body and headers.

Both mod_php and mod_perl can handle this phase, which is needed by 99% of 
the applications, but in addition mod_perl can handle the other phases as 
well, so you could use mod_perl for creating a server that does many other 
things than just a simple web server can do.

Of course, a mod_php user might want to not reinvent the wheel and do some 
low level things, but use other Apache modules like mod_rewrite to do what 
he can't do with mod_php.
With mod_perl though, you can do more.

For example mod_perl allows you to write perl code in the httpd.conf file, 
and this way you can configure the server dynamicly.

Of course for some things you might want to do there are some other mod_ 
Apache modules, but if you want, with mod_perl you can do everything using 
just perl (I hope this is not an exageration.)

Octavian


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by howard chen <ho...@gmail.com>.
On Wed, Jun 4, 2008 at 1:16 AM, Joshua Slive <jo...@slive.ca> wrote:
> On Tue, Jun 3, 2008 at 1:09 PM, howard chen <ho...@gmail.com> wrote:
>
> Yes, if by "embedded" you mean "running in the same process/thread
> space with direct access to the apache API".
>
> Joshua.

The difference is, say using mod_perl, modules are long live as long
as Apache is running and global variables can be shared across request
from different clients.

If you changed the Perl module (pm), restart of server is needed.

While php don't have this issue. Each request is completely isolated.

So this is why I am asking the difference between mod_perl & mod_php
in term of Apache processing, what are the difference.


Howard

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Joshua Slive <jo...@slive.ca>.
On Tue, Jun 3, 2008 at 1:09 PM, howard chen <ho...@gmail.com> wrote:
>  It is probably true that mod_perl exposes
>> more of the API than any other similar module.
>>
>> Joshua.
>>
>
> Yes, this is the point which I don't understand.
>
> Since Perl is embedded into Apache, so is mod_php mean php interpreter
> also  embedded into Apache into the apache?

Yes, if by "embedded" you mean "running in the same process/thread
space with direct access to the apache API".

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by howard chen <ho...@gmail.com>.
 It is probably true that mod_perl exposes
> more of the API than any other similar module.
>
> Joshua.
>

Yes, this is the point which I don't understand.

Since Perl is embedded into Apache, so is mod_php mean php interpreter
also  embedded into Apache into the apache?

Howard

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Joshua Slive <jo...@slive.ca>.
On Tue, Jun 3, 2008 at 12:32 PM, howard chen <ho...@gmail.com> wrote:
> On Wed, Jun 4, 2008 at 12:24 AM, Matus UHLAR - fantomas
> <uh...@fantomas.sk> wrote:
>>
>> - mod_php interprets PHP files and sends them to client
>>
>>
>> If you want apache to parse perl scripts in the same way as mod_php does
>> with php scripts, you need to install an apache module that will do that.
>>
>
> Yes, I believe mod_php is also closer to apache, as contrast to php
> running as cgi mode.
>
> So althought say mod_perl, mod_php, mod_python... all calling mod_xxx, they
> processing model are not the same.

You still aren't explaining what you really mean by "processing model".

All modules have access to exactly the same apache module API. The
difference is in how much of this API the various scripting modules
expose to their scripts. It is probably true that mod_perl exposes
more of the API than any other similar module.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by howard chen <ho...@gmail.com>.
On Wed, Jun 4, 2008 at 12:24 AM, Matus UHLAR - fantomas
<uh...@fantomas.sk> wrote:
>
> - mod_php interprets PHP files and sends them to client
>
>
> If you want apache to parse perl scripts in the same way as mod_php does
> with php scripts, you need to install an apache module that will do that.
>

Yes, I believe mod_php is also closer to apache, as contrast to php
running as cgi mode.

So althought say mod_perl, mod_php, mod_python... all calling mod_xxx, they
processing model are not the same.


Howard

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Difference in mod_perl & mod_php

Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 04.06.08 00:11, howard chen wrote:
> People saying that mod_perl is closer to the Apache core,
> as it can be used to write Apache module, but in fact, what are their
> difference in term of processing model?

what do you mean by "processing model". Those two are completely different
things

- mod_perl inserts perl interpreter to apache, allowing accessing apache
  internals, modify apache's behaviour

- mod_php interprets PHP files and sends them to client


If you want apache to parse perl scripts in the same way as mod_php does
with php scripts, you need to install an apache module that will do that.

Yes, the module can be written using mod_perl functionality.
-- 
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
"To Boot or not to Boot, that's the question." [WD1270 Caviar]

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org