views:

32

answers:

3

I am a total newbie in servers/hosting etc, although I have some experience in programming in C,Java,etc. So excuse me if the question is 'absurd'.

I recently bought service from a hosting site,namely this(hostmds). I have some code I've written in C++ and I want to run it in the hosting site. So my question is:

  • Is this possible, or will I have to rewrite everything in a new language?
  • What should my approach be?

Edit: I have a Shared-Hosting account.

+1  A: 

What type of hosting is this? What kind of application is this, is it a daemon?

Depending on the amount of access rights you have, you can run the code in the cgi-bin folder or through the shell of the server.

Depending on the OS/compiler you've used to write your code in you might have to modify some things so that it'll work on the target OS. You should probably add some more details. :)

Chaoz
The application will be a daemon. I use shared-hosting.
urashima
+1  A: 

Many hosting services provide CGI/FastCGI/SCGI that can be used for running C++ webapps. However, it depends on your host whether you can actually do this, as it may be difficult to get binaries built on some other system to run on the web hosting service (if you even can upload them in the first place).

On shell services and virtual servers you can also run daemons (that directly listen to a port), but especially on shell services you cannot listen on low ports (0..1024), for security reasons.

Notice that the cheapest hosting packages generally only allow PHP at most, so you will need something more expensive for more access.

It is best to ask the hosting provider for further information, as these things wildly differ from host to another.

Tronic
So if i understand correctly I need to upload my binary compiled in my OS to the CGI directory, right?
urashima
The binary needs to be compiled for the hosting service (its CPU, OS, library versions, etc). This is why it is complicated if you don't have shell access or - even better - a virtual server.
Tronic
+2  A: 

You will have to get a "virtual private server" account from your host in order to do this. This will enable you to compile your program on your host machine and run it essentially as if it were a separate machine under your control.

This means you will also be responsible for maintaining your own HTTP server program (such as Apache, if running on a Linux/Unix host), and your own database servers and other support.

If you have a "shared hosting" account (the most common low cost option) with SSH support, you may be able to compile your program, and even run it, but you will be subject to the whims (capricious or otherwise) of the administrators of your system (that it, you may find that libraries you need are removed or moved around)

Vincent Marchetti
+1 Good answer!
Tronic
I have shared hosting account. So can I compile my program on the server?
urashima
If your shared hosting allows SSH access (that is, you can open a terminal and login to an account on your host) then:You might be able to run a compiler (i.e. gcc) using your C++ source codeand your host might have all the libraries you need to link (either statically or dynamically), and your host might give you permission to execute the new binary the compiler generates -- these are decisions your hosting provider makes
Vincent Marchetti
Thanks Vincent that was helpful.
urashima