0

I need to run a PHP script 24x7 on the server I'll be hosting my website on (Probably Godaddy). The PHP script's job is to open a socket and wait for incoming connections. Once a connection is established, it receives some data from 'Somewhere' and pushes it to a database. The data from this database will be constantly accessed by my index.php and will be used accordingly having some particular frequency.

The code is all ready and is working perfectly on my LAN using WAMP. But I am absolutely clueless on going about doing this in hosting accounts. I am guessing SSH, cron and cPanel is the way but no idea on how to do it and connect. Please elaborate the entire process and suggest some readings.

closed as too broad by dan Apr 10 '16 at 4:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Does the script require super privileges to be executed ? With any shared hosting account you will get jailed shell access. If it required root privileges, you won't be able to execute it in shared hosting environment. – MilesWeb Apr 6 '16 at 13:49
  • 1
    Even then, most hosts will not allow you to run an unknown or unauthorized network service which is what you are describing. Certainly not on a shared server. It is a security risk. – closetnoc Apr 6 '16 at 13:53
  • If it so, what else can i do? Get a static ip and host this project through my own PC? Any other way around this? @closetnoc – Kushal Kumar Apr 6 '16 at 13:55
  • Some hosts may allow it, but it will be on a dedicated server. I used to be a web host. I would only allow it after a code review. Most hosts will not do a code review. There are web hosts that are designed for a more professional level of service and not for the masses. Keep that in mind. Most that are designed for the masses will either say no because it does not fit their business model or say yes because they are low quality and do not care. Some are very capable of handling these types of requests. But your code must be solid. – closetnoc Apr 6 '16 at 13:59
  • That was very valuable! Thanks a lot! okay so lets just say that they have reviewed it and gave the green signal. Whats next? How to actually run the script continuously in background? Would it be really long cron jobs? or some strange things called daemons? @closetnoc – Kushal Kumar Apr 6 '16 at 14:05
1

Many hosting companies have in their terms and conditions bans on any background processes which just sit there waiting for connections, additionally they firewalls servers against incoming connections on ports not used as standard on the server for what they believe the server should be used for. As I recall GoDaddy has this restriction on all shared and semi-shared hosting services and only allows this on virtual servers or dedicated servers. To do what you are wanting to do you would need to have a virtual server or dedicated server hosting account which will give you a greater level of access to the server itself and will avoid the strict restrictions applied to shared servers.

Not the answer you're looking for? Browse other questions tagged or ask your own question.