I installed node.js on linux server. I'm able to run node.js on command line, but not able to run on browser.
Did I clearly explained what I want?
I have a domain ram.com that point to particular location on my server /var/www/html/ram.com/.
I created node.js pages on this location /var/www/html/ram.com .How can I access this page on browser?
My apache running on 80 port. Can you explain any changes in apache configuration?
I'm new to node.js can you explain clearly.
To use Node.js to serve your website, you just need to type node yourFileName.js in command line to start the server.
I don't really know how your pages look like. You need *.js files as Node.js source files, and Node.js work as backend. If you mean *.html, you can access them when the server program is running.
Actually, Node.js has its own built-in web server, just like PHP + Apache. So you don't need to use Apache, and I don't think Node.js and apache can work together without other tools.
This is my first answer in Stack Overflow, hope that can help you.
Related
I have question about how to set Node.js server application. On my server I have ColdFusion application server. I can test my code through browser url. I would like the same for Node.js. Node is already installed on my server but the only way to run the code is through cmd command window. First question is what I need in order for both to run on the same server? I still need my ColdFusion. Second question is about Nodes.js and can I set up server application with ISS or I need something else? Also do I have to specify what extension on my files will point to ColdFusion and other to Node. For example .cfm extension is for ColdFusion and .js is for the Node. If anyone knows anything about this or where I can find more information please let me know. I never experienced something similar and this is something completely new for me.
I know this is an old post but I figure I'd provide an answer for those souls who are looking around.
If working with Apache 2.4.x.
In a test environment this would not be to much of an issue as Node and Coldfusion operate on different ports.
If your looking to create a production site than I would say that building a virtual host with proxy to the node site and Coldfusion would be another method.
If you are using the Coldfusion connector to Apache and loading node, than still loading the proxy for the node part would be fine, just make sure you are pointing to the correct port for your node.
Things to remember:
You may have to alter internal Firewall rules.
Comment your hosts files so you don't accidentally alter the wrong file.
Both can exist within the same platform.
This might be a stupid question, but can I setup node.js to run an environment like WAMP? Just to test html docs, JavaScript, Json and Ajax requests.
If this is a good idea or possible, anyone have an advice on setting up the file structure?
You're misunderstanding some Node.js fundamentals. Let's break this down...
WAMP
W - Windows
You can install Node.js on Windows here. Nothing special.
A - Apache
While you can put Apache in front of node as a load balancer, for development purposes it's likely unnecessary. Node.js doesn't need Apache, or nginx. It will happily serve HTTP responses all on its lonesome.
M - MySQL
Sure, use MySQL if you want. :) You'll want to install MySQL on your machine, then you can get a driver for it on npm: https://www.npmjs.com/package/mysql
P - PHP
Node.js doesn't run PHP (barring a few most unholy abominations). Try taking a look at Jade.
The Basics
After you get Node.js installed, I'd recommend taking a look at Express and Jade. Start with the Express hello-world. You can run it simply by opening a command line, navigating to the project directory, and running node hello.js (or whatever you named the file). Just like that, you'll be serving HTTP requests. No need for a "stack".
Why is it necessary to restart a NodeJS server when there is a file change? Do other servers like Apache, IIS, nginx require this as well or can they restart automatically?
You don't say which files you're talking about so I'll mention the issues with a couple different types of files.
For Javascript files that make up your Javascript code for your node.js server, node.js is a continuously running server. That means when the server starts up, it parses your Javascript code into memory and then starts executing it. That server process stays running until you stop it. Because node.js is a continuously running server, if you want to update the Javascript files that make up the server code, you have to stop the server and restart it to let it load and reparse the newly changed source files.
This is very different than something like PHP with Apache that runs a given PHP script from scratch for each separate request. Since there is no long running PHP application and each PHP script is started from scratch for each request, then it can automatically pick up a newly changed PHP script without restarting the Apache server. If you had a long running server written entirely in PHP, then it would likely have similar behavior as node.js.
And, if you wanted to upgrade your Apache server code, you'd have to restart Apache (as with node.js).
You can kind of think of node.js as Apache + PHP in one since the functions of both are generally met by just node.js by itself. It integrates the web server functionality with the webapp logic whereas those are separate with Apache + PHP.
For HTML files or Javascript files that are served by the server and delivered to the browser, you will generally not have to restart the server for the new versions of those files to be served on subsequent browser requests. But, this depends a bit on which server framework you are using and how exactly it implements file caching. This behavior is not specific to node.js, but would be built into whatever code you were using to serve files by your web server (e.g. Express or something like that).
I am wondering if you can deploy Meteor apps to a Windows based Wampp stack... Such as The Uniform Server.
I am wanting to upgrade a project to Meteor that is running on a small internal network. I plan on using the existing mysql database.
I'm not quite sure on how deploying works. I know it creates a tarball, but does this just unzip into the www folder on the server? I will also have Node installed.
I'm new to this whole node.js environment. That's not an actual server that can be used for production is it? It's a bit confusing. I've only ever used wampp stacks. I can't use anything but windows, so Linux is outta the question for a server.
Thanks in advance.
L.
WAMP stands for Windows, Apache, MySQL, and PHP.
Meteor uses Node.js, not PHP.
Support for other databases are coming - See the roadmap
See this question
NodeJS apparently works on Windows - here are the two top Google links.
tl;dr No
I am coming from Microsoft world so please bear with me on this. I was told I could install node.js and use that as a web server instead of IIS. This is a very small business application. In IIS I can create virtual directory and point to the location of the web page and everything works just fine. Based on very little I read, I have few questions;
Is it possible to run node js as a windows service or any other form so that it runs for ever? I did find the forever package that I think I can use.
In IIS, I can create virtual directory set the port and thats it, I have myself a website.
I do not see any examples where I can use a directory where I have a web page, written in java script and point it to run as a web site. All the examples have some thing like server.js and that runs and routes the call. what is the other way to host web sites and use node.js to simple run as a fast web server.
I was told I could install node.js and use that as a web server instead of IIS.
This is true, but as you already found out then you are in charge of providing for things that IIS was already doing for you (e.g. automatically restart on reboot, or on crashes, hosting multiple sites by creating virtual folders, et cetera.)
You can indeed get all of these things worked out in Node.js and there are several libraries that help on each of these areas. It's not too hard but you'll need to do a bit of researching.
You can also run Node.js behind IIS. Take a look at iisnode http://tomasz.janczuk.org/2011/08/hosting-nodejs-applications-in-iis-on.html
Is it possible to run node js as a windows service or any other form so
that it runs for ever?
The library Forever takes care of restarting the site when it crashes...but I don't know if you can run it as a Windows Service. I haven't tried that.
In IIS, I can create virtual directory set the port and thats it,
I have myself a website.
I assume you are talking about a site that serves static HTML files, right? If that's the case that's very easy to support in Node.js either writing your own web server or using Express.js to serve static files.
I do not see any examples where I can use a directory where I have a web page,
written in java script and point it to run as a web site. All the examples
have some thing like server.js and that runs and routes the call.
Here is an extremely simple example to serve plain HTML files in Node.js https://gist.github.com/2573391 Don't use this in production, though. It's just an example and it does not have any kind of error handling or security.
what is the other way to host web sites and use node.js to simple run
as a fast web server.
As others have said, you should look into Express.js http://expressjs.com/ It provides some of the infrastructure that you are very likely going to need when building traditional web sites.
You say you're running a "very small business application" behind IIS. Unless it's written for Node.js (in JavaScript), it won't work.
There are no examples pointing to a directory and running that as a website, because that's not how things are done in Node.js. You write a Node.js-application and pull in a webserver-library.
Put simply, In Node.js, you don't embed the appliation in the webserver; you embed the webserver in the application.
When I used node.js, I redirected HTTP requests by a proxy server, nginx. I don’t know if you can directly bind node.js as an HTTP server, but for what’s it worth, nginx is pretty nice!
First things first, allow me to share an introduction. IMHO you should take this decision ( of moving from IIS to nodeJS) by adding various parameters. I belong to the Java & PHP community yet I use NodeJS to achieve extremely specific implementation where NodeJS perform the fastest ( fast IO, AJAX-JSON responses & more ). As you are coming with a Microsoft background you should bare with less comfortable solutions.
Yes, its possible to run NodeJs as a windows service and Forever will do fine.
and yes you can create "Virtual Directories" but by creating symbolic links to each of your customer's web site.
I recommend to take a good look at bouncy & express, If you're willing to take this step then these packages is just what you need.
Cheers!