Page 1 of 1
Customize for PHP?
Posted: Wed Jun 28, 2006 2:58 am
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.
Posted: Wed Jun 28, 2006 3:41 am
by Ambush Commander
I'm not exactly sure what you are asking. Do you mean have Apache run PHP files?
Posted: Wed Jun 28, 2006 4:42 am
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
Posted: Wed Jun 28, 2006 10:07 am
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?
Posted: Wed Jun 28, 2006 6:18 pm
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.
Posted: Wed Jun 28, 2006 9:53 pm
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?
Posted: Thu Jun 29, 2006 11:25 am
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.

Posted: Thu Jun 29, 2006 1:16 pm
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...
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...
Posted: Thu Jun 29, 2006 3:41 pm
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....
Posted: Thu Jun 29, 2006 8:41 pm
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!
Posted: Sat Jul 01, 2006 7:54 am
by David_Irving
Ok, Nemmind, Feegured eet all out.
Thankyou all, once again, Thankyou.