Does Wamp server handle mutiple HTTP connections? - php

I am creating an application on the phone that queries to the server. The server side scripting is done in PHP. Do i have to create threads to handle multiple http requests or does wamp provide for it. How does Wamp handle multiple HTTP requests?

WAMP runs an instance of Apache. Apache can handle many HTTP requests. Your web application determines how those requests are handled.

Apache does that for you. That's the point of having a HTTP Server (serving multiple clients).

Related

Is there an Apache-like Websocket server solution that handles php scripts?

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?
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

Can i use Node js, Websocket and php in the same apache server?

I was wondering if its possible create a website combined with NodeJs, Websocket and php in the same Apache server. Is there any documentation that can i read?
"In the same Apache server", No. node.js does not run in Apache. It runs by itself.
But, you can use multiple technologies on the same server. For starters, you could have two completely separate web servers running on separate ports, one that was Apache + PHP + webSocket and another that was node.js + webSocket.
But, node.js does not use Apache. Instead, node.js would typically be configured to be it's own web server all by itself. So, you don't typically run an Apache server and have some requests through it go to PHP and some go to node.js.
Using PHP and node.js together depends entirely upon what you're trying to do with them. You could have your web server as a node.js server and then have some requests that node.js receives actually execute some PHP and get the results from running a PHP script. And, you could do the reverse too with a PHP script fielding the request and then manually running a node.js script for some requests.
To answer any more fully, we need to know what you're really trying to do with PHP, node.js and webSockets.
FYI, you could set up an NGINX proxy on port 80 and configure it to direct some requests to your Apache/PHP server (running on a different port) and other requests to your node.js server (running on a different port). Incoming webSocket requests would then be directed to one of the two servers.

Apache and NodeJS on the same server. Can they talk to each other?

I've got Apache (running PHP and serving static content) and NodeJS (for websockets) running on the same server under the same domain (different ports). I'm not using nginx. I've already got the webclient communicating to both successfully, but now I want to close the communication loop and have Apache and NodeJS talk to each other.
It makes sense that they should be able to talk to each other, but I'm not entirely sure the best way to make it happen. What methods are there, and which way do you suggest?
If you are talking about the communication of the app running on apache and node app, yes it is possible. You just have to write the interfaces of your applications as services, then you can just use standard HTTP methods for communication.

Is there a way to run websockets without a server side php websocket server that runs constantly?

Let me clarify
I played with phpwebsockets and see that it requires a websocket server to run forever/constantly to keep the states etc in the memory is there any way to run websockets when there is no way of running a server on the server side?
You can used a hosted realtime service, such as Pusher who I work for. Here's comprehensive list of realtime hosted services.
There will always have to be a server of some sort listening constantly. For example, HTTP traffic is delivered by a web server (Apache, Nginx, Lighttpd, etc.) that is running constantly.
It is possible for a web server to spawn a new PHP based process, then hand the client's connection over to the new process. However, none of the major web servers currently do this, and the paradigm for web server modules that route WebSocket traffic is to send the connection over to an existing, constantly running server.
You would have to write your own custom web server in order to keep from running a WebSocket server constantly... and then, really, what's the point, since you're still writing your own constantly running server?

Difference between web-server and servlet container

What is the difference between "A Web Server" and "A Servlet Container"?
In general are all Web Servers Servlet(Web) Containers too or vice versa?
I have been using Apache Tomcat for JSP and Apache for PHP but unable to figure out the exact difference between those two, where exactly lies the difference?
I tried searching previous threads but could not find much.
Thanks! :-)
A Servlet Container is a Web Server that must be able to run Java Servlets.
Web Server, on the other hand, is a broader term including all software running and communicating through HTTP protocol.
Under these definitions:
All Servlet Containers are Web Servers
Not all Web Servers are Servlet Containers. I.E. Apache HTTP Server can not run Java Servlet directly.
HTTP is the Hypertext Transport Protocol. Both Apache and Tomcat will accept HTTP requests.
The difference is that Apache is JUST an HTTP server. It serves up static HTML pages.
Tomcat has an HTTP listener inside it, but in addition to that it has a servlet/JSP engine. It can serve up both static and dynamic HTML pages.
You can use Tomcat without Apache.
Apache cannot handle servlet/JSP requests without having a servlet/JSP engine bolted on top of it
ServletContext is an application specific object, whereas ServletConfig is a Servlet specific object..
ServletConfig object is created as Web container instantiates the respective servlet

Categories