ASP.NET and PHP
PHP is a language almost entirely dedicated to the web and PHP runs "embedded" next to HTML, other languages are basically languages, what they handle is input and output, in case output is what will generate the page and routes.
So in PHP at least on most servers when you request something like http://site/pagina.php
Apache/IIS/Ngnix (fast-cgi, fpm, etc) will pass the pre-processed input data to PHP to manipulate into its variables and anything it writes in PHP with echo
, print
or even write an HTML directly will be considered "output" which in this case is to generate a response in the "HTTP" format, basically because PHP was designed to do just that, although there are many PHP frameworks that change the behavior a little.
So basically just take the content and drop it in the folder htdocs
/public_html
/www
if it’s PHP.
In the case of C# what is used for web is the "platform" Asp.net, it is almost like PHP, it is possible to create pages with some "embedded" codes in the middle of HTML that everything will be processed as HTTP response and it is still possible to write something in the main class that is "behind", in Asp.net-mvc is different because it follows a certain architecture a little more complex and I can’t say how it is, in general the language runs side by side with the files .aspx
or with the control of the Response
yet the deploy is easy on IIS (Apache-like server used mainly for Asp.net pages and the like) as it is almost up to the folder via FTP or drop to the main server folder if you have access.
Other languages and "platforms"
Languages like Ruby and Python and programs like Node.js do not interact with the Web directly, they use modules, frameworks and platforms that make the language communicate with the server, in practice we could say that PHP also does the same thing, but the difference is in how it treats the "output", these languages do not work "embedded" with the html/txt/etc content, they intermediate what is received and process the response
note in the case of Rails the framework written in Ruby is what makes the "web" part, although there are other less popular framework
For example in Python to "write" an HTTP response would have to do something like this (source: https://wiki.python.org/moin/BaseHttpServer):
import time
import BaseHTTPServer
HOST_NAME = 'localhost'
PORT_NUMBER = 80
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(s):
"""Resposta HTTP para o GET"""
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
s.wfile.write("<html><head><titleTeste</title></head>")
s.wfile.write("<body><p>Isto é um teste.</p>")
s.wfile.write("<p>Você acessou: %s</p>" % s.path)
s.wfile.write("</body></html>")
if __name__ == '__main__':
server_class = BaseHTTPServer.HTTPServer
httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
print time.asctime(), "Servidor iniciou - %s:%s" % (HOST_NAME, PORT_NUMBER)
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
print time.asctime(), "Servidor parou - %s:%s" % (HOST_NAME, PORT_NUMBER)
Basically it was written a server in Python, of course this is a much more complex example, in Python there are frameworks the WSGI module that makes use python with Apache (outside that it is possible to use CGI)but this is the part considered difficult to configure the WSGI module with your framework and make the necessary notes, of course many servers that offer support for Python already have this on Cpanel of life and clearly you must hire a service that supports this.
Another example is the Node.js which is software to run JS without browser, it is usually used for servers, however when doing this (using Express):
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Olá mundo!')
})
app.listen(3000, function () {
console.log('Exemplo de servidor local na porta 3000!')
})
We just create a port for local access like http://localhost:3000/
to set up for a more complete server is usually done using proxy-reverse with Nginx (maybe there are other ways), the same could be applied to the example with Python.
Responding
This has to do with the way the language was built?
Not necessarily with the language, but with the whole application, in this case the PHP interpreter was built like this, providing support for Web and command line (CLI)
but when it comes to moving up such an application in a VPS for example, it’s so much more work?
It depends a lot on how the server is, have servers that is already all ready just hit one or another detail, usually just point to the local port, as 3000 or in case Python with WSGI point the location of your file .wsgi
for example /home/user/projeto1/hello.wsgi
(in these two cases assuming there is a configuration panel)
Concluding
What makes PHP and ASP.NET easier to deploy
PHP together with Fast-cgi or FPM or Apache2handler are made to work with popular servers known as Apache, Nginx, IIS and Lighttpd and then just drop in the folder named "root" that the scripts will be interpreted as pages after processing through "apache"+"module"+"php interpreter".
ASP.NET is a platform for web, and also just "drop" the files in the folder you want (I’m not necessarily talking about Asp.net-mvc)
Other languages/platforms are not "WEB", they are only languages that are interpreted or compiled, so it is usually necessary to configure something like the reverse proxy I mentioned earlier and this is often done manually.
Of course depending on the service they hire they have easier ways, as simply port the local port you will use and the rest they are already configured.