夏期劇場
夏期劇場

Reputation: 18325

Ratchet: Should leave it run as a Server via "php" command, manually?

I'm a LAMP guy, and now start learning WebSockets via Ratchet. So far so good following the start up docs here, and hence i'm able to run the Ratchet Server, like this:

$ php server.php

And then my Javascript Clients can connect to it, etc.

But..

As a LAMP guy, i'm very used to have Apache (or) NGINX as the "Server" for any PHP files to serve to public. Now... should i just run that above command in my terminal, and that's gonna be the Ratchet Server?

Is there a way NOT to run the server like that? (or) Is there a way to let Apache (as an example) manage the Ratchet Server? Which means, let Apache start/stop the Ratchet whenever i type:

$ service httpd start
$ service httpd stop

I'm more confident this way. Plus, the SSL handling, etc also would be then done by Apache more easily. Am i right please?

Please kindly suggest, as i'm very new to this area. Thanks all :)

Upvotes: 0

Views: 1833

Answers (1)

mitchken
mitchken

Reputation: 800

You indeed are right that running it in the command line is not a production ready solution.

In the last page of the tutorial (deployment) there are some ways to do it. For example, hypervisor is entirely explained how to set it up there.

If you don't like hypervisor usage, then you could try to just write a shell script which is executed on startup, that starts the server.php (less good solution, yet easier)

The ssl part you want to use is possible using a proxy with apache.

If you are using Apache web server (2.4 or above), enable these modules in httpd.conf file :

mod_proxy.so

mod_proxy_wstunnel.so

Add this setting to your httpd.conf file

ProxyPass /wss2/ ws://ratchet.mydomain.org:8888/

If you have any more questions please let me know.

Upvotes: 1

Related Questions