in reply to Perl - webserver

If you really want to write your own webserver, you could do worse than taking a look at HTTP::Server::Simple or HTTP::Server::Brick for inspiration.

There does not seem to be firewall modules on CPAN, but there is a module called Hook::Filter which builds a "firewall" around subroutines and has a rule-based set-up with the rules found in a configuration file. Again you can "steal" probably some techniques from this module.

Not being a PHP-person, I guess that you will somehow have to call the PHP interpreter with the PHP-file as an argument. It does seem possible to run a PHP program outside of a web-server: Stand-alone PHP.

Update: Some more info on how to use PHP "stand-alone" is in this article:PHP Standalone Scripts. If the PHP-interpreter is in your PATH it could be as simple as: my $return_code = system('php my_standalone_script.php');

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: Perl - webserver
by aufflick (Deacon) on Apr 13, 2008 at 04:11 UTC
    I am happy you consider my HTTP::Server::Brick a reasonable example of Perl webserver implementation - thanks!
Re^2: Perl - webserver
by Anonymous Monk on Mar 26, 2008 at 10:00 UTC
    http://pastebin.com/f19194081 that's what i have done so far :s any idea ?
      I had a look at your code, but even when not being a networking-guru, I can see some problems:
      • You should use strict; and use warnings; to guard against silly mistakes, bad constructs and simple typos.
      • It is really a bare-bones, down-to-earth, ultra-simple type of webserver and as little as I know of it, web-servers are all but bare-bones, down-to-earth, ultra-simple kind of things. I'm not sure it is not full of ugly security holes, although you do some sanitizing of the request string.
      • It can handle only one connection at a time.
      • It can do no authentication / authorization.
      • ...
      Don't misunderstand me, I am not saying your code is not an honest try at writing (the beginnings of) a webserver, but these things are quite complicated by nature and without a good game-plan you are likely to bump into some issues later on and will have to start all over from scratch.

      As I am against re-inventing wheels, personally I would start with an existing design (see the links in my previous post) and adapt it as needed.

      CountZero

      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James