I've got a small node.js and socket.io project that i would like to run online on my server. I used jade for my files, and packaged it plete using npm install. So everything is in my local folder. I can also run it locally which works.
But i want to connect my phone to control my browser and i can't connect my phone to a localhost. So I need to run it online.
The problem is when I put it online i've got a index.jade file. This one doesn't get recognized by the browser as webpage. So i only get a forbidden page when i go to
my folder structure is like:
└── httpdocs
├── iphoneconnect
| ├── node-modules
| ├── express
| ├── jade
| └── socket.io
├── package.json
├── server.js
└── views
├── index.jade
└── mobile.jade
Do I need to use a special host for it? Or can someone point me in the right direction! Thanks in advance.
I'm trying to make something like this:
If anyone got a good tutorial for that would be nice! I only would like to know how to set up the connection between iphone and webbrowser! Already got something right now but it's bit slow.
Greets,
Wouter
I've got a small node.js and socket.io project that i would like to run online on my server. I used jade for my files, and packaged it plete using npm install. So everything is in my local folder. I can also run it locally which works.
But i want to connect my phone to control my browser and i can't connect my phone to a localhost. So I need to run it online.
The problem is when I put it online i've got a index.jade file. This one doesn't get recognized by the browser as webpage. So i only get a forbidden page when i go to http://www.woutervdkamp.nl/iphoneconnect/views
my folder structure is like:
└── httpdocs
├── iphoneconnect
| ├── node-modules
| ├── express
| ├── jade
| └── socket.io
├── package.json
├── server.js
└── views
├── index.jade
└── mobile.jade
Do I need to use a special host for it? Or can someone point me in the right direction! Thanks in advance.
I'm trying to make something like this: http://sportyfinger.lecoqsportif./uk-en/connexion
If anyone got a good tutorial for that would be nice! I only would like to know how to set up the connection between iphone and webbrowser! Already got something right now but it's bit slow.
Greets,
Wouter
Share Improve this question edited Jul 2, 2014 at 9:15 Dieterg 16.4k3 gold badges33 silver badges50 bronze badges asked Jul 2, 2014 at 8:58 user2023106user2023106 4- You can connect your phone to your local network and access your dev machine by putting its IP and port in the cell phone – fmsf Commented Jul 2, 2014 at 9:01
- I don't think this is related to node at all. The "Forbidden" message is sent by Apache. You haven't told us enough about your configuration though. – Prinzhorn Commented Jul 2, 2014 at 9:02
- I would still like to host it online afterwards so still need a solution :) And thanks for the advice, didn't know that. Will give it a try. – user2023106 Commented Jul 2, 2014 at 9:02
-
3
I guess you have a fundamental misunderstanding of how this is supposed to work. Do you even have a node process running? Do you have a
/iphoneconnect/views/
route in your express app? – Prinzhorn Commented Jul 2, 2014 at 9:04
2 Answers
Reset to default 6First of all, you might got lost in understanding what is happening.
Your current method is to serve node.js project as static site, using Apache.
That is not going to work, your node.js project consists of instructions, and to parse these instructions you need a program. That program is called node.js, not Apache or anything else.
Most webhosting panies you will find do not support node.js at all. The solution is to find a specific node.js hosting service or virtual/cloud hosting instead.
Some of appropriate for the task hosting panies 1 are: Heroku, OpenShift, Digital Ocean.
After choosing, you will have to setup simple Linux server using the supplied colorful guidance and then install node.js program before running your project.
After you have Linux ready, you have to install node.js there and run your project the same way as if it was on localhost.
Summarizing all I said:
- Find the hosting pany with node.js or shell access.
- Setup linux OS (I suggest Ubuntu) through the hosting pany tools. (easier than it sounds, don't worry)
Run the following mands to get node.js on your fresh linux server:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs
Copy the project files to the server
- Navigate to the project location on the server and run it as you would do on localhost:
node.js server.js
1 - Comparison of Hosting panies by @Vinz243
I am also doing some simple node.js web app recently and I think Heroku is a very friendly hosting websites for new developers.
For hosting on heroku, you do not need to run sophisticated bash mands. The method that heroku remends is that you install a tool called heroku to the terminal but it is not necessary. Just add a remote to the heroku repository(which you can create on their website) and push your source code to that remote repository and you can see from the mand line that heroku will automatically detect, pile and host the node.js web application for you.
git push heroku master
btw, Heroku also has database and logging add-ons.
For your reference:
https://devcenter.heroku./articles/getting-started-with-nodejs
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745209700a4616760.html
评论列表(0条)