This is a discussion on socket programming within the PHP General forums, part of the PHP Programming Forums category; Hi to all, Is it possible to run php in the web running in a specified port without installing apache ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
This is a reply to an e-mail that you wrote on Tue, 15 Jul 2003 at 09:33, lines prefixed by '>' were originally written by you. > Hi to all, > Is it possible to run php in the web running in a specified port > without > installing apache in Linux? > Can anyone give a sample code for this? I'm searching this for a week > but i > really can find one. Please help us. You could use inetd and the command line PHP binary. How to do it varies between linuz distros, basically it allows you to assign a port number to any program in the system and all the program has to do is send it's output to the standard output (use echo in the case of PHP). David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) |
|
|||
|
Michael P. Carel wrote:
> Hi to all, > > Is it possible to run php in the web running in a specified port without > installing apache in Linux? > > Can anyone give a sample code for this? I'm searching this for a week but i > really can find one. Please help us. > > > > Regards, > > Mike > Do you mean to host websites with ONLY php and without webserver? Or do you mean using PHP for something else then web, to make it listen for incomming connections? If the second, you might want to look here: http://se.php.net/manual/en/ref.sockets.php Maybe that helps. //Simon |
|
|||
|
> > Hi to all,
> > > > Is it possible to run php in the web running in a specified port without > > installing apache in Linux? > > > > Can anyone give a sample code for this? I'm searching this for a week but i > > really can find one. Please help us. > > > > > > > > Regards, > > > > Mike > > > Do you mean to host websites with ONLY php and without webserver? Or do > you mean using PHP for something else then web, to make it listen for > incomming connections? Actually i want to create a server utility that can be administered through web via a certain port, i'm afraid not to use php as an apache module because the server might have an existing webserver installed, so i came out into an idea to use php cgi/cli to run in a specified port and view it in the web. It is somewhat similar to some existing utilities such as WEBMIN which use perl cgi, but i really dont have a very good start since i dont have enough examples for this. I've already opened opened port for this as what David said but i cant see the output in the web. He'res what i've did in my Redhat linux 6.x inetd.conf: samples stream tcp nowait.1000 root.root /usr/local/mikecarel/samples samples services: samples 6886/tcp samples: #!/usr/local/bin/php -q <?php echo "Content-Type: text/html;charset=iso-8859-1"; echo "\n"; echo "<html>hello </html>"; ?> Am I in a right track? or is it possible with this? Do i missed something here? Thanks in advance. Mike |
|
|||
|
--- "Michael P. Carel" <mikecarel@teamglac.com> wrote:
> Actually i want to create a server utility that can be > administered through web via a certain port, i'm afraid not > to use php as an apache module because the server might have > an existing webserver installed, so i came out into an idea > to use php cgi/cli to run in a specified port and view it in > the web. This is pretty easy to do, but I should warn that PHP's socket support is still labeled as experimental, though I have found it to be very stable, and I know of no plans to change the API. Quite a while ago now, I wrote a simple HTTP proxy in PHP that listens on port 4887 by default. It is a single script, so it is pretty easy to follow, and you're welcome to check it out at http://protoscope.org/. It is probably a better example than I could come up with here. Hope that helps. Chris ===== Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ |
|
|||
|
Hello,
This is a reply to an e-mail that you wrote on Wed, 16 Jul 2003 at 01:34, lines prefixed by '>' were originally written by you. > I've already opened opened port for > this as > what David said but i cant see the output in the web. > He'res what i've did in my Redhat linux 6.x <snip> > Am I in a right track? or is it possible with this? Do i missed > something > here? I am not very familiar with *nix administration at all so if anyone wants to jump in and correct anything I have said wrong feel free. Maybe try and have the command inetd is set to execute as /usr/local/bin/php -q /usr/local/mikecarel/samples instead of using a shebang line and having your PHP file executable and see if that works? David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ (developed entirely in PHP) |
|
|||
|
> Quite a while ago now, I wrote a simple HTTP proxy in PHP that listens on
port > 4887 by default. It is a single script, so it is pretty easy to follow, and > you're welcome to check it out at http://protoscope.org/. It is probably a > better example than I could come up with here. > I've downloaded your scripts and tried to test it on my server. Please correct me if im doing it right. I've opened services and port from the server to automatically run protoscope only during acces in the given port (http:\\myserver.com:4887) : inetd.conf: protoscope stream tcp nowait.1000 root.root /usr/local/mikecarel/protoscope.php services: protoscope 4887/tcp My question's are : 1. How could i access the rest of my php script residing in /usr/local/mikecarel/ (http://myserver.com:4887/index.php) ? 2. If ever does the POST and GET method works properly on this? 3. Do I still need to install apache? Hope I understand your application correctly. Mike |
|
|||
|
--- "Michael P. Carel" <mikecarel@teamglac.com> wrote:
> I've downloaded your scripts and tried to test it on my server. > Please correct me if im doing it right. I've opened services and > port from the server to automatically run protoscope only during > acces in the given port (http:\\myserver.com:4887) I always just leave it running when I use it, but your method would probably work as well. > My question's are : > 1. How could i access the rest of my php script residing in > /usr/local/mikecarel/ (http://myserver.com:4887/index.php)? Well, I meant this as a simple example of socket programming in PHP more than anything. Since the application is an HTTP proxy, you would set up your browser to use a proxy (specifying the host and port Protoscope is running on), and then just type http://myserver.com/index.php in your browser's location bar (assuming a Web server is running on myserver.com). The method you mention makes the browser think it is contacting an HTTP server, which is a bit different, so that wouldn't work. > 2. If ever does the POST and GET method works properly on this? Yes, but only as an HTTP proxy. > 3. Do I still need to install apache? If you want to connect to myserver.com and have it handle HTTP requests, then you will need a Web server. If this is what you're looking for, you might be interested in another PHP project called Nanoweb, which is a Web server written in PHP. Because this task is much more complicated, the project is more complicated as well, so it may not be the best learning example. You can learn more about it here: http://nanoweb.si.kz/ Hope that helps. Chris ===== Become a better Web developer with the HTTP Developer's Handbook http://httphandbook.org/ |
|
|||
|
|