PHP Websocket server in Linux hosting [closed] - php

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have a GoDaddy Linux hosting , any idea how do I run a websocket server for my HTML5 web app ? Any other recommendation ?
I know VPS can do it, but it is costly , any PaaS solution ?

If you have a shared hosting plan, you will very likely not be able to access sockets, thus making it impossible to use the WebSocket API.

You're going to need a virtual private server for this one.
If you got that set up you can take a look at socket.io and node.js which does exactly what you're looking for. There are a couple of examples of how to set it up on their websites plus you can take a look at this blog post which has some examples on how to set up node.js and socket.io with html5's canvas and websockets to have some realtime drawing going on.
Edit: Theres a second option of running a php based socket server, although not as good as the option above, but it can probably(?) be done without vps.
PHP has seme basic functions to create a socket server that are listed here. There are a couple of examples of how to set it up such this. And theres also this stackoverflow answer here that lists a couple of google code projects that does exactly what you need such as this.

The best PHP WebSocket self-hosted/install solution right now is Ratchet.
However, as stated by #HartleySan, you're unlikely to be allowed to use a WebSocket solution on a shared plan due to the requirement for persistent connections. This is especially the case with general PHP solutions that allocate a large amount of resource to each request. Ratchet may have worked around this, I don't know.
IMHO the best solution for PHP is to use a hosted service such as Pusher, who I work for. There are other realtime web hosted solutions available too. This means you offload the persistent connections to the hosted service and can use your PHP stack in the normal way.
Also related: OpenShift, a PaaS, have written an article which covers the challenges of WebSockets. This helps explain the problems that other hosting providers are having when supporting WebSockets.
OpenShift do have WebSocket support in preview so you could try them out. But that is obviously a problem if you've already paid for your shared hosting. As above, I'd recommend a hosted service as the best solution.

Related

what is the best way to handle real time notification in php? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I want to implement real time notifications like in Facebook. There might be a huge number of notifications to be sent for different users, depending on server load time and efficiency of coding. Which is the best approach?
1. using normal AJAX?
2. with node.js and socket programming?
3. something else?
Thanks in advance.
The choice of the proper platform greatly depends on your current architecture, knowledge, and budget.
Your question suggests that it is web based, for which there are only two basic options:
WebSocket: There exists many WebSocket server solutions including compiled executables, PHP based, and Node.js. This approach is greatly gaining in popularity but isn't necessarily accessible to every budget since it usually requires a complete server to run. VPS limitations are usually too important for systems that require so many simultaneous connections.
AJAX: The use of AJAX and its variants is still a very popular solution and, when well implemented, can be almost as efficient as WebSocket without the need to sustain the connections constantly. It doesn't often matter if there is a one second delay, and Facebook chat is usually much slower than that.
For non web-based solution, anything is possible. If you develop a client-server application, you can have real time connections similar to WebSocket which can be even easier to maintain.
Ajax request not real time but you can set timeout and in this case work.
but the ajax request busy your server and try to many connections. this is simple !
If you use socket it's better but you need more time to develop this.
Read the following link can help you :
Ajax vs Socket.io
Nowadays we have two possible solutions. WebSockets and Comet. WebSockets are probably the best solution but they’ve got two mayor problems:
Not all browsers support them.
Not all proxy servers allows the communications with websokets.
Because of that I prefer to use comet (at least now). It’s not as good as websockets but pretty straightforward ant it works (even on IE).
realtimenotifications more details To know more about refer above link.

Transferring my site on Apache server to AWS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I've developed a site in PHP using xampp's Apache and MySQL servers. I didn't keep the prospect of hosting it in AWS in my mind and so I was wondering how much should I change my site to host it on AWS. And I wish to change it as little as possible.
Can someone point me to a definitive guide to AWS site hosting of a php site that's developed for Apache?
Thanks.
So long as your PHP code is well written, it should be pretty portable. There is no definitive guide that I know about for XAMPP->AWS deployments, but you should find it pretty easy to spin up an EC2 instance and test your app before public launch. Is there some aspect in particular that you are worried about in terms of the migration, or is it just a general concern? If it's just a general concern i.e. you just haven't done it before, keep in mind that you can easily destroy and re deploy your AWS server, so I would recommend that you just give it a go and then come back here and post any errors that you run into... also the guys over at https://serverfault.com/ (don't worry, it's affiliated with Stack Overflow) might be better placed to help you out.
It has less to do with XAMPP => AWS, and more to do with:
Which OS are you moving from/to?
Which generation of PHP are you moving from/to?
AWS services like Elastic Beanstalk and OpsWorks use Amazon Linux as their base OS (related to CentOS and RHEL), but with raw EC2, there are tons of different supported OS's (e.g., Ubuntu, Slackware, Fedora, Debian, CentOS, Amazon Linux). In both cases, you have full root access to the machines.
Also, make sure you're using the same generation of PHP (e.g., 5.3, 5.4, 5.5, HHVM) between your current server and the AWS server. This will prevent things like language/syntax differences between the two environments.
Like Nicholas Byfleet said, "So long as your PHP code is well written, it should be pretty portable."

Can php and C++ run on the same server and communicate in a web site? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I have a client that wishes to have a website written that involves a fairly simple cms driven website that sorts and displays daily reports. The website will require subscriptions and include membership, free trials, etc...
Originally I was going to write the site in PHP, as none of the requirements are too heavy and I am very experienced in it. However, after speaking with the client, he has worked closely with someone who has a C++ product that offers a workflow that includes the entire process of handling subscriptions, logins, and trials and (apparently) can be used on a web platform.
This throws a wrench into my original plan, because even though I know C++ I have never had to deploy it on a webserver or have it communicate with PHP. I've already written a good deal of the site in PHP, so would prefer not having to re-write.
Can I have the two communicate on the same server? What would be required to do so? Would it be worth my time or should I just decide to scrap PHP and use C++? Or should I tell my client he's nuts?
That's about all the info I have about the project right now. Not sure if I can provide much more info, but will try if it's needed.
Thanks for all answers.
Tel him he is nuts.
The reason is that none of those tasks requires the benefits C++ can offer over PHP. It is heavy maintenance pain. And in the big picture putting those two together is more work (in hours) than writing those things in php.
The only thing that would justify C++ is if there is some heavy math business logic involved in there. And i mean heavy.
For problems. Just think about debugging.
In addition to what Thomas says (which is all true), your hosting company will most likely prohibit running custom binaries. Hosting packages short of virtual private server normally don't allow user-written compiled code on the Web server, only scripts.
VPS hosting is, on average, 5 times as expensive.
You can re-write the C++ code in PHP. You can also convert C++ to Java using a converter and then use the Java virtual machine if your host allows that. You can use the C++ code if your host allows that. You can host the C++ code from a local machine if that is a good idea in your case.
I would tell the client that in case there is no explicit need for the C++ language I would go with implementing PHP. You know, the communication between C++ and PHP adds to server load even if the host allows you to use the C++ module. And in the future you will have a lot of pain maintain

Node.js + Socket IO + Apache + PHP cheap webservers? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am new to using node.js and socket io and I am currently hosting my php website on a server, now that I am going to be adding node js and socket io to my website I will need hosting that will allow me to have those, are there any out there or will I need to have my own? I am hoping to have a cheap hosting service as this is just to have my site hosted while in development, once I am finished with it I plan to have my own server set up.
I recommend DMEHosting as a VPS to use for development. Their cheapest Linux VPS is more than affordable and serves your purposes. It will also get you into the basics of setting up a web server on Linux via SSH, which is essential. I recommend reading up on an article on setting on a VPS on Cent OS. Just Google that. You don't really need to learn how to use Linux for now. Just know how to navigate directories and follow tutorials on setting up your own web server.
Edit: Keeping this post as is for historical purposes, but I now recommend an EC2 instance or DigitalOcean.
Here is a list of Node hosting solutions. However, if you want to be able to have Node.js + PHP and Apache, you will need to use your own server, like a VPS. Popular options are Linode, Slicehost, Amazon EC2 and Fanatical. Note that the VPS option will require good knowledge of Linux.

PHP instant messaging methods [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want to make an IM so that user's can send instant messages to each others on the same page like a chat. Users can choose that who can see their messages. Its for task management . What is the best method that I should use for. I'm using php. Is php sockets usefull for this? or Polling, Comet, php output buffer or javascript timer(timer is easy but not fast).
The most frequently used method is called COMET.
Here is a PHP implementation: How to implement COMET with PHP
In the HTML5 specification there are something called websockets that many browsers already have implemented. Here is a PHP project supporting websockets: phpwebsocket. There are some javascript libraries which can use a flash component if the browser do not support websockets (and therefore be backwards compatible)
imho webSockets is the way to go, although PHP might not be the most suitable backend to handle them.
If you know how to use Sockets then use them; otherwise using AJAX in a timer should suffice so long as it doesn't need to be real-time (5-10 second delays between fetching messages should be OK).
I'd suggest using Socket.IO for this.
You have a few options from PHP:
As pointed out by #jgauffin you could look doing this on your existing PHP server using a Comet using the Comet and PHP option or WebSocket Solution using something like phpwebsocket.
You could create another component dedicated to handling your real-time messaging such as a dedicated Comet or WebSockets process running on you existing hosting or a wholly dedicated server. If you take this approach you could look at using something like socket.io running in node.js or a full third party Comet or WebSockets server.
Finally, you could have a look at a hosted service which would allow you to keep your existing development and production environment and you could then layer on the real-time chat. One such service called Pusher (which I work on) handles all the real-time messaging infrastructure in addition to providing added functionality specifically developed for making chat applications easy to build. It also means that you don't need to upgrade your hosting if you are using something like shared hosting where things are tightly locked down and you can't easily install your own components.

Categories