Customize for PHP?

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Customize for PHP?

Post by David_Irving »

How do i customize my (own made) website for using the php engine? I've been running off Apache for quite some time but being a software developer i just couldn't resist. Is there a detailed guide on how to do this?

Thankyou,

David.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I'm not exactly sure what you are asking. Do you mean have Apache run PHP files?
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

I'm writing my own webserver, and i need to know what i need to do for it to execute PHP files. Do i just execute it then send it the file link then..?

I have no idea.

Thanks,

David
Jixxor
Forum Commoner
Posts: 46
Joined: Wed Jun 07, 2006 5:53 pm
Location: Lakeland, FL

Post by Jixxor »

I believe Apache just invokes the php.exe file whenever it encounters a PHP file or code.

So a simple file path and code for your web server that directs it to use the php.exe everytime it encounters a PHP file or code to render it would work?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I recommend you research FastCGI and SAPI. You can either use PHP has a CGI module, or you can integrate it as a module as long as you implement SAPI.
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

Jixxor wrote:I believe Apache just invokes the php.exe file whenever it encounters a PHP file or code.

So a simple file path and code for your web server that directs it to use the php.exe everytime it encounters a PHP file or code to render it would work?
So would that work like parameters? Say i execute php.exe (say having "C:/phpscripts/test.php" for parameter one) what would happen next? It would just compile it? Wheres the output?
Jixxor
Forum Commoner
Posts: 46
Joined: Wed Jun 07, 2006 5:53 pm
Location: Lakeland, FL

Post by Jixxor »

David_Irving wrote:
Jixxor wrote:I believe Apache just invokes the php.exe file whenever it encounters a PHP file or code.

So a simple file path and code for your web server that directs it to use the php.exe everytime it encounters a PHP file or code to render it would work?
So would that work like parameters? Say i execute php.exe (say having "C:/phpscripts/test.php" for parameter one) what would happen next? It would just compile it? Wheres the output?
It's been a while since I've gone exploring into the web server arena, especially that of Apache. When installing PHP on a machine also housing Apache, one just simply had to add/edit a few lines in Apache's httpd.conf file that would provide Apache with the path to the PHP.exe file and included some other directives (can't recall exactly). Apache can also run PHP as a module through the php4apache.dll (or php5apache,dll) file using the text:

Code: Select all

LoadModule php4_module "c:/php/php4apache.dll" // Load php4 as a module for Apache
in, again, the httpd.conf file.

Perhaps you can use this information to further study how Apache uses the PHP engine? I've always understood things by tearing them apart, see how they work, and then putting them back together... it might work for you too. :P
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

David_Irving wrote:
Jixxor wrote:I believe Apache just invokes the php.exe file whenever it encounters a PHP file or code.

So a simple file path and code for your web server that directs it to use the php.exe everytime it encounters a PHP file or code to render it would work?
So would that work like parameters? Say i execute php.exe (say having "C:/phpscripts/test.php" for parameter one) what would happen next? It would just compile it? Wheres the output?
PHP I blieve can be executed 2 ways:

1) CGI
2) CLI

As a CGI module, PHP is run as a thread/process inside Apache...under Windows anyways...or is what I remember anyways... :P

This means...PHP is only ever loaded once, when Apache is first fired up...and it stays resident in memory until Apache or the system is restarted...

This saves you the cost and overhead of re-loading an application and leads to better performance...

CLI (Command line interface) is the example you have given...

This has the disadvantage of shutting down everytime the script completes and starting back up every times you call a script...

The output is sent to STDOUT so your web server would have to capture that and forward the output appropriately...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Actually, when PHP is executed as CGI... For every request that involves PHP processing, a PHP instance (CLI) is spawned.. And then the environment variables are filled by the webserver... Which PHP can happily use... This spawning of all these instances doesn't scale very well... (More info on the Common Gateway Interface: http://www.w3.org/CGI/)

To improve this, most webservers apache (via modules) and iis (via isapi) load a couple of these instances in memory... And reuses these... This increases performance drastically... (More info on apache: http://httpd.apache.org/docs/2.0/developer/)

I presume you'll probably start with an implementation of CGI in your webserver... And if you're really into a challenge, build a concept that allows the user to have a pool with instances of whatever interpreter/request-handlers....
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

OkOK!

I got CLI working, does that work the same way as it would when executing CGI?

Simply sending the link, then it sends its output to the console? Man i so hope so, you guys have made me all happy by explaining it, i still just NEEd to know for CGI, thankyou ALL so much!

Dave!
David_Irving
Forum Newbie
Posts: 8
Joined: Wed Jun 28, 2006 2:55 am

Post by David_Irving »

Ok, Nemmind, Feegured eet all out.

Thankyou all, once again, Thankyou.
Post Reply