a port to php
Moderator: General Moderators
a port to php
I want to explain what i want to do...
Whe take one linux server, with some apache... a littlebit of mysql and a lot of php....
Now whe have a nice working server that resonds on port 80.. And i can configure this to any port that i want....
But... Now i want to do this. Without apache...
I a other way sayed: binding a port to a specific php script. So if this script is behind port 80, i have to do all the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> apache normalie does for you... (ps: it's for a note system ATnotes)
What do i have to do/change i'm thinking in some commandline php scripting, but how/why/when...
I allready searched the internet for this, but it's linux that i'm stuck in...
Whe take one linux server, with some apache... a littlebit of mysql and a lot of php....
Now whe have a nice working server that resonds on port 80.. And i can configure this to any port that i want....
But... Now i want to do this. Without apache...
I a other way sayed: binding a port to a specific php script. So if this script is behind port 80, i have to do all the <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> apache normalie does for you... (ps: it's for a note system ATnotes)
What do i have to do/change i'm thinking in some commandline php scripting, but how/why/when...
I allready searched the internet for this, but it's linux that i'm stuck in...
you might bind a socket, accept connections and handle the requests yourself within a php script (not to mention that a scheduling for concurring requests would be nice, too)
With the words of Cpt.Picard: "But the question remains: Why? What is its purpose?"
It wouldn't be easier...
With the words of Cpt.Picard: "But the question remains: Why? What is its purpose?"
It wouldn't be easier...
The purpose... 
It's a note system that whe use here.
The idee is, to note the 'server' with a question like. 'REQUEST CONTACT INFO ABOUT somebody'.
And the server notes the results back.
The problem is, i don't want the webserver to get in the progres..
I understeand from your functions that the script has to run 24h7?
I just want the script to run when a note is recived.
It's a note system that whe use here.
The idee is, to note the 'server' with a question like. 'REQUEST CONTACT INFO ABOUT somebody'.
And the server notes the results back.
The problem is, i don't want the webserver to get in the progres..
I understeand from your functions that the script has to run 24h7?
I just want the script to run when a note is recived.
- Heavy
- Forum Contributor
- Posts: 478
- Joined: Sun Sep 22, 2002 7:36 am
- Location: Viksjöfors, Hälsingland, Sweden
- Contact:
If you don't want apache, write another server that responds to a protocol of your own choice on a port of your own choice.
The closest way to get a PHP script run on request should be a web server. If you configured for example apache to have your script as an index file, you could do:
http://your.server/?CMD=blablabla+blabla+blablabla
...and get the response you tell PHP to generate.
Isn't that easy enough?
Why write a whole new server for this?
You could go calling PHP your script as a shell command. Then there is no apache around. Binding it to a port is beyond my knowledge at the moment.
The closest way to get a PHP script run on request should be a web server. If you configured for example apache to have your script as an index file, you could do:
http://your.server/?CMD=blablabla+blabla+blablabla
...and get the response you tell PHP to generate.
Isn't that easy enough?
Why write a whole new server for this?
You could go calling PHP your script as a shell command. Then there is no apache around. Binding it to a port is beyond my knowledge at the moment.
For the PHP script to only run when the port is connected to, something MUST sit between the connection and PHP. This is usually apache. If you want something else, see the options above, or make your own server to handle it all as welll as interrogate PHP. Otherwise, the script will have to sit around, busy doing nothing, until someone 'note's the script.
That's just the way it works, there is no other way that I know of (and I feel I know enough to make that a definitive reply)
That's just the way it works, there is no other way that I know of (and I feel I know enough to make that a definitive reply)
Re: a port to php
It seems I've seen this question somewhere before. Sitepoint was it?[]InTeR[] wrote:I want to explain what i want to do...
Whe take one linux server, with some apache... a littlebit of mysql and a lot of php....
Now whe have a nice working server that resonds on port 80.. And i can configure this to any port that i want....
But... Now i want to do this. Without apache...
I a other way sayed: binding a port to a specific php script. So if this script is behind port 80, i have to do all the s**t apache normalie does for you... (ps: it's for a note system ATnotes)
What do i have to do/change i'm thinking in some commandline php scripting, but how/why/when...
I allready searched the internet for this, but it's linux that i'm stuck in...
Anyways, what about inetd or xinetd? Check them out. They will listen on a port and based on configuration open up a script or program based on input for a specific port.
The other option is to just write a server (in PHP) or use one of the existing ones. There is PatServer, PHPServ, and Nano. Goggle or AllTheWeb will help you find 'em.
As for writing command line scripts in PHP, it's really no big deal. Check the online manual. There is a section dedicated to this.
Cheers,
BDKR
You may want to have a look at Nanoweb, a webserver written in PHP. It's pretty full-featured, but the source is quite easy to follow, so you could probably go through and pick out quite a few features that you don't need.
EDIT: Also, phpserv is a 1-file php daemon, with very good performance, It might be easier to adapt than Nanoweb.
EDIT: Also, phpserv is a 1-file php daemon, with very good performance, It might be easier to adapt than Nanoweb.