472,354 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

Perl vs PHP?

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
Jul 17 '05 #1
4 2309
On Sat, 04 Jun 2005 23:49:46 +0000, Keith wrote:
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


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.

--
Demagogue: One who preaches a doctrine he knows to be untrue to
men he knows to be idiots.
H.L. Mencken

Jul 17 '05 #2
In article <pa****************************@sbcglobal.net>,
Mladen Gogala <go****@sbcglobal.net> wrote:
On Sat, 04 Jun 2005 23:49:46 +0000, Keith wrote:
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


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.


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...

Jul 17 '05 #3
Keith wrote:
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


Are you asking what the difference is in how Apache handles PHP and
Perl/CGI or the differences in the languages themselves?

--
"If you don't stand for something, you'll fall for anything..."
Jul 17 '05 #4
In article <WM*****************@newssvr17.news.prodigy.com> ,
DarbyCrash <bo*******@gmail.com> wrote:
Keith wrote:
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


Are you asking what the difference is in how Apache handles PHP and
Perl/CGI or the differences in the languages themselves?


Semantics of each language aside, both perl and php can be "called" as a
CGI process or as part of the Apache server in a module. I use perl as
a CGI and CGIwrap when I want to set the code to restrict permissions on
who can read it. I can't do this with php since it runs as the Apache
user within the Apache process because my ISP doesn't offer php as a CGI
program.

--
DeeDee, don't press that button! DeeDee! NO! Dee...

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
13
by: Otto J. Makela | last post by:
I'm trying to install to php the Perl-1.0.0.tgz package (from http://pecl.php.net/package/perl, enabling one to call perl libraries) to a pre-existing Solaris system. Unfortunately, the attempt...
6
by: surfivor | last post by:
I may be involved in a data migration project involving databases and creating XML feeds. Our site is PHP based, so I imagine the team might suggest PHP, but I had a look at the PHP documentation...
4
by: billb | last post by:
I installed a perl extension for PHP to use some perl inside my php primarily because I have perl working with oracle and not php and oracle. So I want to use my old perl scripts, and use the...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made but the http to https rule only works for...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.