0

As I was beginning to tool around a bit with node, I was told that I needed to undergo a little bit of a paradigm shift since I was coming from a PHP background. I would ask questions like, "I have my script working in terminal, now how can I upload it to the server and access through an AJAX request?". I was told that "it doesn't work like that" and that "Node scripts aren't just that magically work like PHP when you upload them to a server. Node IS a server".

So I thought to myself, "Okay. Let's just put this on the shelf for a while." I basically only use node for scripts that I run locally anyway, so if I have to type node server.js in terminal to use my script, it wasn't that inconvenient, and it allowed me to happily learn it without having to worry about shifting any of my paradigms.

Then, last week I made a small front end that worked with some node scripts I was writing and I realized that I needed members of another team to use it. I guessed that they weren't going to have Node installed or be comfortable enough with a CLI to type node server.js. I found out about Heroku. And I uploaded all my scripts to it, and you know what: it magically works! Paradigm shift avoided AGAIN.

I feel like continually having avoided this paradigm shift is hurting me. So I need to figure it out. How node can be a server? Yet also node files can be uploaded to something like Heroku (/Docker? Another "container" I've heard discussed) and work in the same way as I'm used to server-side PHP running? Yet, it seems, at the same time not: I can't upload them to an Apache server I don't think and expect them to work. Also, since I've mentioned Docker, once I understand exactly what Heroku is, is Docker basically the same thing?

(I felt this question is correct for this SE site, but please let me know if you think it would be a better fit on SO or somewhere else)

3
  • What is the actual question? Commented Jan 13, 2016 at 19:23
  • @RibaldEddie All of the sentences preceding ? glyph.
    – 1252748
    Commented Jan 13, 2016 at 19:27
  • I can't tell if it's "what is the difference between nodejs as a server and Apache+php as a server" or "what is the difference between heroku and Apache"? Is this a question about containers or servers or what? Commented Jan 13, 2016 at 19:31

1 Answer 1

6

Node is a javascript execution environment. Node can act as a server (by executing a script that performs server functions).

Heroku is an operating system (sitting in the cloud) that supports (among others) Node scripts. You can think of it like your desktop sitting on the internet, running a Node environment.

When you run a server type of script in Heroku, it isn't any different than you running it on one your companies public facing servers.

One of the nice things about Heroku over Apache, is that Heroku is designed to allow users to upload applications without an admin being required to deploy it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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