No, and yes.
In principle, you can do that, but it is not quite that easy. Google for "cgi" or "common gateway interface", or read
this primer to get an idea how this works.
Also, you must make sure that you enable cgi in your web server (which may be a security issue, you may want to think twice about that).
Cgi is not necessarily enabled by default on a web server (or available at all), and if it is enabled, it usually only works in one specific subdirectory (so it also matters where you upload your program to).
Lastly, it does matter what kind of Linux you use insofar as you may use an incompatible version of glibc or any other library that you link to. So yes, you have to take care of that.
EDIT:For completeness: Besides CGI, there is also FastCGI (which is supposedly faster
) and the possibility to incorporate executable code into a web server via some plugin mechanism (most major servers support that). Both FastCGI and plugins have the advantage that they do not need to reload the executable for every request.
I cannot tell you much more about FastCGI since I have never used it, but I guess it does not matter a lot unless you plan to run your program 100 times per second. Writing a module/plugin is evidently a lot more complicated than a simple CGI, so that is probably not what you want, either.
Unless whatever you want to do is about some insane number crunching or similar things, you might consider a script language, too. For example PHP is available nearly everywhere (even the cheap web hosters offer it), and it is a mighty fine thing. You have a syntax very close to C/C++ (learning time is almost zero), there is a function for almost everything (including database handling, networking, graphics and all kinds of weird stuff), the documentation is excellent, and execution speed is not a lot worse than a real executable. Using PHP, you can reduce the amount of time to write a "typical" web application to maybe 10% of what you would take doing it in C/C++.