简体   繁体   中英

Running websocket server on amazon EC2

I've written a web socket server that listens to a specific port. In order to run it I log in to EC2 instance with putty and run:

php server.php

I was wondering if this is the only and the right way to do. Normally copy my php files to the host via ftp would be enough, I don't understand why the php command needs to run the server. Any help is appreciated.

This question is not about any particular coding problem, so is considered off-topic in terms of StackOverflow.

The way PHP works - is just a script file. Same as bash (.sh), python (.py), node.js (.js) or any other similar.

They all in fact have to be executed. In common world, Apache , nginx or any other web server will do execute those scripts for you for each request is made to web server.

As you are creating socket file, you need to create it yourself, as it creates one socket and php script will continue working as long as it will by it self. It is not executed per each request. In fact make sure it is not executed by apache so do not put in usual website directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM