Is it possible to use Node.js as a PHP file without starting the server?

I am currently in Node.js and love how I can use my front-end knowledge to create server-side applications. However, what I like about PHP is that you can just publish or run / open the file, and it will automatically start by the server. What I don't like about PHP is the syntax and speed. I want to use Node.js and Javascript for all my server functions (e.g. billing script or registering script).

So ... Is there a way to run the Node.js application, as it would with a PHP script, and I mean without creating a constantly working server and executing "node app.js" in the terminal for each script? Like ... Is there some kind of nginx thing I can write to make this work? I do not want to run the entire site on the Node.js. server

+4
source share
1 answer

Node.js is not a server. You can create a server with Node.js using modules such as ExpressJS. But Node.js is a runtime environment for evaluating and running Javascript outside the browser.

So this means that if you have a hello.js file containing one line:

console.log("Hello World");

and ran

node hello.js

, script, "Hello World". node . "sever" .

====================

Edit:

, node js Apache , Apache php. node Apache, http://larsjung.de/node-cgi/

, "", Apache, ExpressJS node.

+2

Source: https://habr.com/ru/post/1538883/


All Articles