1

There are a lot of examples of implementing a TCP/IP-WS stack in all kinds of languages, also in PHP/CLI. But that is not what I'm looking for.

For http protocol there is Apache webserver software. It listens on default http port 80 for incoming requests. On shared hosting servers it can host an array of domain names and the incoming request url is mapped to the right served directory/file in the "hostAccountDir/domainName/docRoot/".

In this model each PHP script is a "specialized HTTP/application level" server; and does not need to invent/implement the TCP/IP-HTTP stack. Fortunately Apache does that for all PHP scripts.

Is there such a thing for Websockets, listening on port 9000(?), forking to the served directory/file... etc?

2
  • Interesting question. Can you clarify why a php cli tool run by a supervisor is not suitable? Commented Dec 27, 2016 at 5:39
  • • I am looking for ways to get more cohesion in application files. If I have a application directory with websocket parts, I would like to have the client and the server parts in that same directory. • It is not allowed on shared hosting servers to take a TCP/IP port and start a server. • An Apache-like websocket server that forks/maps request by URL to the right application level php file seems like a good solution for shared hosting servers. Commented Dec 27, 2016 at 14:06

1 Answer 1

1

Apache powers more than 70% of websites today, but new alternatives are gaining market share. Apache is a reliable server, but it takes considerable memory to run. In some situations other web servers can perform better. The best-known alternative open source HTTP servers are lighttpd, nginx, and Cherokee.

PHP-FPM can listen on multiple sockets. It also listen on Unix sockets, or TCP sockets.

nginx is an HTTP server and mail proxy server. It has been running for more than two years on many heavily loaded Russian sites, and it has become more popular in the rest of the world, to the point where today it’s used by 6.5% of all websites.

For more details refer to the links below.

https://serversforhackers.com/video/php-fpm-configuration-the-listen-directive

https://linuxaria.com/article/apache-alternatives-for-serving-php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.