First off, websockets is a different protocol entirely from HTTP, so relying on Apache is unnecessary. You might still use Apache so you can point a web browser somewhere, but fundamentally, when your Javascript client code connects to your websocket server, your websocket server should not be running through Apache.
If you really must use PHP for a websocket server, I recommend that you run PHP on the command line and make it run in the background indefinitely. This is important because your code that implements the websocket server should never terminate. Your websocket code will listen on the port number of your choice. Personally, I use ports 9000+, but the choice is up to you.
I think it is vital to note that the language you choose for your websocket implementation can be entirely different from the language you use to process HTTP requests. Personally, I use PHP for HTTP requests, but my websocket server (which provides a real-time video game) is written entirely in C++. The actual client code that connects to the websocket server is written in Javascript.
For a variety of reasons, I think you should choose either C++ or Java for your websocket server, largely because good support libraries exist in those languages, and if desired, you'll have access to strong multi-threading capabilities. If you want recommendations for websocket server implementations in those languages, you can ask me and I'll mention some that work.
Lastly, I want to add that when I decided to write a websocket-based server, I first investigated the possibility of implementing it in PHP, but quickly decided that C++ would work better for my needs. Hopefully you are also able to switch to C++ or Java (or possibly Ruby) as well.
Chatexample from github.com/morozovsk/websocketphp index.php start? Or does your command line pause?PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/mysqlnd.so' - /usr/lib/php5/20090626/mysqlnd.so: cannot open shared object file: No such file or directory in Unknown on line 0. And pauses.helpfulnote, Charles.