473,659 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2404
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****@sbcglob al.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.c om>,
DarbyCrash <bo*******@gmai l.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
8131
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: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br>\n"; print STDERR "PERL This is text sent to STDERR<br>\n"; $output="PERL Some output:<br>\n"; for ($i=0; $i<5; $i++) {
31
4778
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 great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
0
9738
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
13
3253
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 fails in a rather dramatic way, spewing out thousands of "relocation remains"... I'm somewhat lost on what to do next, the documentation that came along with the Perl package is somewhat sparse. Anyone have suggestions? % uname -a
6
2994
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 for one of the Pear modules for creating XML and it didn't look like much. I've used Perl XML:Twig and I have the impression that there is more Perl stuff available as well as the Perl stuff being well documented as I have a Perl DBI book, a Perl...
4
3697
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 functionality of php. The extension uses the '$perl->eval' function. i am kind of stuck with the syntax or how to put the php variable into the perl script. I have a form where the user puts in a grid reference. Then a php script that gets the...
21
34385
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
1
47445
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.