I agree with Sgarissta. On Windows, you do have the option of using COM. And you could build a COM object to do your IO handling. But then you have the problem of *nix. For that, you would need to write an app for it (although it wouldn't be able to interface as cleanly as COM would).
I've got some X10 gear at home. Its controlled by a serial connection. Running from Linux, there's a command line tool that you can run. I have PHP issue an exec() to that command line tool and just change the command line parameters. It works well for what I need.
I've also played with parallel port gadgets. I created a C++ DOS app that could flip the data channels open and closed. This was enough to toggle reed switches open and closed which could drive 12v gadgets like fans and buzzers. That was fun to play with. I rigged it to a web page via several batch files. One to actually run the C++ program. One to monitor for a request. I think I had a batch file that just sat listening to see if a particular file got created (it was created by my PHP script and had the request info in it). Then when it found the file, it called my C++ program which knew to look for the file and would read the parameters in. This isn't glamorous, but with the tools I had available, it worked.