50

Been seeing a lot of how to's on how to install nodejs but nothing is at all clear.

So I ask...

Can someone provide a step by step installation guide for installing and using nodejs on a xampp server?

Kendall
  • 5,065
  • 10
  • 45
  • 70

7 Answers7

32

After searching (source), I have found, that it's easier to install Node.js directly (so, no need of XAMP/WAMP):

  1. Install http://nodejs.org/download/

  2. Create a test file (example) C:\myFolder\test.js and put this code in that file:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
  1. Open CMD (COMMAND PROMPT) and execute:

    node C:\myFolder\test.js

  2. Open this address in your browser: http://127.0.0.1:1337/

T.Todua
  • 53,146
  • 19
  • 236
  • 237
  • I wonder if this even works if you do not have admin rights. I am looking for a solution to let my students use node.js in a classroom on machines which are managed remotely and on which the students have no admin privileges. – Kristian Heitkamp Aug 20 '21 at 22:21
25

Now It's really easy to install and use Node.js even with Apache if you are using Xampp/Wamp etc. Because unlike old days, now Node.js org has created MSI installer for windows. Below are the steps to install Node.js with Apache. It is assumed that you have already installed xampp

Download windows installer of Node.js from it's site http://nodejs.org/ click on download. Hit the Node.js website and click the big green Install button. It'll detect your OS and give you the appropriate installer. If for some reason it doesn't, click the downloads button and grab the one you need. Run the installer. That's it, you have installed Node.js and, equally, NPM – Node Package Manager – which lets you add all kinds of great stuff to Node quickly and easily.

Note

Keep your Apache and Node ports different. Declare Node port other than 80 or 8080 while creating server in Node because these are the default ports of Apache.

May be these Notes may help someone in future.

1) When Node.js is installed Node and NPM become available globally. Means that you can create your site anywhere on your hard drive and with command prompt go to your directory like in Windows Command prompt

d:/NodeSite/node server.js

and now you can access it via

http://localhost:3000

because your server.js is running with node.

2) Similarly, you can install any Node Package like installing Memcached package or Library

d:/NodeSite/npm install memcached

"NodeSite" is a folder contain your project. You can see that node and npm have become globals.

Airy
  • 5,484
  • 7
  • 53
  • 78
  • 11
    How does this answer the question about installing node on apache? You just write about node.js and how you run that, which is not what the question was about. – Kevin Simper Mar 05 '14 at 11:27
  • 6
    It's simple. The question is about installing node with xampp on same machine. And that's what i have answered and about running node is just to let people get started with that.:) – Airy Mar 08 '14 at 04:49
11

XAMPP and a node.js is two different things, which do not need to work together, nor do they need each other.

XAMPP consists of Apache, MySQL, PHP and Perl.

Where node.js is just like PHP or Apache, so an application.

Node.js can be installed from the website, http://nodejs.org or via the terminal following these instructions:

https://github.com/joyent/node/wiki/Installation

Stacky
  • 875
  • 9
  • 24
Kevin Simper
  • 1,669
  • 19
  • 32
  • 1
    Oh wait.. so if I install node on my localhost, does that mean I can get to it from another computer via ip address inside the local network? I know Xampp works that way, but will node? – zipzit Nov 08 '13 at 21:19
  • 1
    Yes, you can get node to answer on port 80, you like apache answers on port 80, like you are used to. – Kevin Simper Nov 10 '13 at 15:15
  • What is it that you do not get? – Kevin Simper Jan 16 '14 at 15:58
  • @KevinSimper Don't I need to install node to a directly location on localhost? So then how do you explain installing it on a host server? – Kendall Jan 29 '14 at 15:15
  • 1
    localhost is not a location ;) it is the name given to yourself when you try to access a web page from the server itself – happy Feb 19 '14 at 22:15
11

It is possible to run NodeJS trough Apache/XAMPP. Great tutorial how to setup httpd.conf / vhosts.conf http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache

<VirtualHost 109.74.199.47:80>
    ServerName thatextramile.be
    ServerAlias www.thatextramile.be

    ProxyRequests off

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    <Location />
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </Location>
</VirtualHost>

In the end it would be accessible trough port 80 thatextramile.be

Evalds Urtans
  • 6,436
  • 1
  • 41
  • 31
11

I never gave a lot of answers on this site. Because most of the time I'm not an expert however. I had the same issue a while back.

1) You don't really need this XAMPP. Node will create its own http_server so I suggest you just forward calls from XAMPP to the Node app.

2) a good start would be: nodeguide.com/beginner.html

3) I work with PHPstorm which is very nice for Node.js development.

3a) Node.js plugin -> https://www.jetbrains.com/phpstorm/help/installing-updating-and-uninstalling-repository-plugins.html

3b) read this: http://blog.jetbrains.com/webstorm/2014/01/getting-started-with-node-js-in-webstorm/

3c) running: http://blog.jetbrains.com/webstorm/2014/02/running-and-debugging-node-js-application/ 3d) Test your app. You mighht also need this:

4) (MysQl db) https://codeforgeek.com/2015/01/nodejs-mysql-tutorial/

Adam Azad
  • 11,171
  • 5
  • 29
  • 70
user3806549
  • 1,428
  • 1
  • 17
  • 25
2

If you want to run javascript from apache you can do it as CGI module. It wont be exacly node.js server and performance because Apache is your server, but you can execute node.js like scripts http://www.cgi-node.org/

You must add a handler to your apache configuration to handle whatever extension files for example .jss via CGI modlue that essentially calls node(.exe) depndeing if linux or windows. I made it work under Bitnami WAMP

Pawel Cioch
  • 2,895
  • 1
  • 30
  • 29
1

It is not possible to install NodeJs on Xammp. Because Xammp is is simply a tool where Apache,MySql,FileZilla,Tomcat and Mercury server are available. Where you will be able to only configure and use these server.

If you want to install Nodjs on Windows Machine, You will have to install it manually.

Ari4
  • 860
  • 7
  • 12