So I'm pretty late to the Node.js party. Mainly because nobody invited me... Thanks. That said, I'm starting to work it out. I have come from an ASP classic background so there are a few things I have yet to understand.
If someone can point me in the right direction, that would be great. Thanks in advance.
So, I'm setting up a server the standard way.
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/');
This gives me a nice page at http://127.0.0.1:1337/
. Lovely.
The site I am building resides at http://newsite.dev/
. Is it possible (don't laugh) to setup the node server to run from a sub folder of my site, let say http://newsite.dev/api/
?
So then, any queries from client-side scripts can be sent to /api/
rather than http://127.0.0.1:1337/
.
EDIT:
To make things a bit clearer. I am currently running a custom PHP framework at http://newsite.dev/
, but looking to drop this long term. In the mean time, need to run them in parallel.
EDIT Again, to clarify, I am running everything on my OS X, so apache (MAMP) installation.
You are asking to create a virtual directory and yes you can setup Node.js with PHP but you must do a little reading.
A virtual directory is a website that lives within a folder like www.yourwebsite/myotherwebsite
Here's how to set that up in Apache.
http://httpd.apache.org/docs/current/vhosts/examples.html
Here's how to set that up in IIS.
http://technet.microsoft.com/en-us/library/cc771804(v=ws.10).aspx
You would then need to hook up Node.js with Apache or IIS. Here's more instructions.
Linux: How can I implement virtual directories with node.js and express?
Windows: http://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With