| re: Perl vs PHP?
In article <pan.2005.06.05.04.34.56.728906@sbcglobal.net>,
Mladen Gogala <gogala@sbcglobal.net> wrote:
[color=blue]
> On Sat, 04 Jun 2005 23:49:46 +0000, Keith wrote:
>[color=green]
> > All:
> > What is the difference between Perl (CGI) and PHP (Apache module)? I
> > thought both used servers to direct the
> > user to the appropiate Perl or PHP program in order to execute the program
> > to interpret the user's Perl or PHP script
> > respectively.
> >
> > Keith[/color]
>
> Generally speaking, difference between CGI script and an interpreter
> module is that CGI script will spawn a new process and page in the invoked
> interpreter, be it Perl, PHP or some kind of shell, while module will
> execute in the context of httpd process itself. The price for that is
> growth of the httpd process itself, but context switches are avoided as
> well as the costly interprocess communication. Furthermore, process
> creation is an expensive operation which requires a lock on the kernel
> process table which further reduces concurrency. It is not as expensive as
> $CREPRC system service used to be on VMS, but it's still significantly
> more expensive then executing the interpreter within the context of an
> existing process. Here is what PHP5 interpreter linked as an Apache module
> looks like on FC3:
> # pmap 3519
> 3519: /opt/apache/bin/httpd -k start
> 003b8000 20K r-x-- /lib/libcrypt-2.3.5.so
> 003bd000 4K r-x-- /lib/libcrypt-2.3.5.so
> 003be000 4K rwx-- /lib/libcrypt-2.3.5.so
> 003bf000 156K rwx-- [ anon ]
> 004d4000 912K r-x-- /usr/lib/libxml2.so.2.6.16
> 005b8000 36K rwx-- /usr/lib/libxml2.so.2.6.16
> 005c1000 32K rwx-- [ anon ]
> 005cb000 32K r-x-- /lib/tls/librt-2.3.5.so
> 005d3000 4K r-x-- /lib/tls/librt-2.3.5.so
> 005d4000 4K rwx-- /lib/tls/librt-2.3.5.so
> 005d5000 40K rwx-- [ anon ]
> 005ee000 84K r-x-- /lib/ld-2.3.5.so
> 00604000 4K r-x-- /lib/ld-2.3.5.so
> 00605000 4K rwx-- /lib/ld-2.3.5.so
> 00608000 20K r-x-- /usr/lib/libgdbm.so.2.0.0
> 0060d000 4K rwx-- /usr/lib/libgdbm.so.2.0.0
> 0062d000 8K r-x-- /lib/libdl-2.3.5.so
> 0062f000 4K r-x-- /lib/libdl-2.3.5.so
> 00630000 4K rwx-- /lib/libdl-2.3.5.so
> 006fc000 64K r-x-- /usr/lib/libz.so.1.2.2.2
> 0070c000 4K rwx-- /usr/lib/libz.so.1.2.2.2
> 00723000 1164K r-x-- /lib/tls/libc-2.3.5.so
> 00846000 4K --x-- /lib/tls/libc-2.3.5.so
> 00847000 8K r-x-- /lib/tls/libc-2.3.5.so
> 00849000 8K rwx-- /lib/tls/libc-2.3.5.so
> 0084b000 8K rwx-- [ anon ]
> 0084f000 56K r-x-- /lib/tls/libpthread-2.3.5.so
> 0085d000 4K r-x-- /lib/tls/libpthread-2.3.5.so
> 0085e000 4K rwx-- /lib/tls/libpthread-2.3.5.so
> 0085f000 8K rwx-- [ anon ]
> 008f0000 116K r-x-- /usr/lib/libexpat.so.0.5.0
> 0090d000 8K rwx-- /usr/lib/libexpat.so.0.5.0
> 009eb000 60K r-x-- /lib/libresolv-2.3.5.so
> 009fa000 4K --x-- /lib/libresolv-2.3.5.so
> 009fb000 4K r-x-- /lib/libresolv-2.3.5.so
> 009fc000 4K rwx-- /lib/libresolv-2.3.5.so
> 009fd000 8K rwx-- [ anon ]
> 00c6c000 136K r-x-- /usr/lib/libpng12.so.0.1.2.8
> 00c8e000 4K rwx-- /usr/lib/libpng12.so.0.1.2.8
> 07e7d000 72K r-x-- /lib/libnsl-2.3.5.so
> 07e8f000 4K r-x-- /lib/libnsl-2.3.5.so
> 07e90000 4K rwx-- /lib/libnsl-2.3.5.so
> 07e91000 8K rwx-- [ anon ]
> 08048000 388K r-x-- /opt/apache/bin/httpd
> 080a9000 12K rwx-- /opt/apache/bin/httpd
> 080ac000 1476K rwx-- [ anon ]
> b6c79000 56K rwxs- /dev/zero (deleted)
> b6c87000 516K rwx-- [ anon ]
> b6d08000 4K r-x-- /usr/lib/locale/locale-archive
> b6d09000 24K r-x-- /usr/lib/locale/locale-archive
> b6d0f000 180K r-x-- /usr/lib/locale/locale-archive
> b6d3c000 2048K r-x-- /usr/lib/locale/locale-archive
> b6f3c000 36K r-x-- /lib/libnss_files-2.3.5.so
> b6f45000 4K r-x-- /lib/libnss_files-2.3.5.so
> b6f46000 4K rwx-- /lib/libnss_files-2.3.5.so
> b6f47000 1464K r-x-- /oracle/product/10g/lib/libnnz10.so
> b70b5000 144K rwx-- /oracle/product/10g/lib/libnnz10.so
> b70d9000 4K rwx-- [ anon ]
> b70da000 10772K r-x-- /oracle/product/10g/lib/libclntsh.so.10.1
> b7b5f000 1048K rwx-- /oracle/product/10g/lib/libclntsh.so.10.1
> b7c65000 84K rwx-- [ anon ]
> b7c95000 1912K r-x-- /opt/apache/modules/libphp5.so
> b7e73000 196K rwx-- /opt/apache/modules/libphp5.so
> b7ea4000 116K rwx-- [ anon ]
> b7ec1000 132K r-x-- /lib/tls/libm-2.3.5.so
> b7ee2000 4K r-x-- /lib/tls/libm-2.3.5.so
> b7ee3000 4K rwx-- /lib/tls/libm-2.3.5.so
> b7eff000 112K r-x-- /opt/apache/lib/libapr-0.so.0.9.6
> b7f1b000 4K rwx-- /opt/apache/lib/libapr-0.so.0.9.6
> b7f1c000 4K rwx-- [ anon ]
> b7f1d000 816K r-x-- /lib/tls/i686/libdb-4.2.so
> b7fe9000 8K rwx-- /lib/tls/i686/libdb-4.2.so
> b7feb000 4K rwx-- [ anon ]
> b7fec000 76K r-x-- /opt/apache/lib/libaprutil-0.so.0.9.6
> b7fff000 4K rwx-- /opt/apache/lib/libaprutil-0.so.0.9.6
> bffeb000 84K rwx-- [ stack ]
> ffffe000 4K ----- [ anon ]
> total 24884K
> #
>
> The PHP5 module is linked as a shared library, named
> "/opt/apache/modules/libphp5.so". You can also link perl
> as an Apache module. The mod_perl module can be downloaded
> both from the Apache home and CPAN.[/color]
On the other hand, I'm not aware of any way to run as anything but the
UID and GID of the web server if you execute in mod_{perl,php} mode.
You can, however, use CGIwrap to change the UID/GID of a specific user
and run a child process under that environment.
This is not an issue if you have a dedicated machine that you alone
manage. It becomes an issue if you're running on a shared environment
and want to protect the CGI files from prying eyes of others on the
system with shell access. The other alternative is to put everything
requiring a password into MySQL and use an include directive to define
ENV variables in the httpd.conf, if the ISP admin allows.
--
DeeDee, don't press that button! DeeDee! NO! Dee... |