你如何使用node来index.php或index.html,所以当你去blahblah.com时你的节点网站会加载。
如果app.js正确,现在浏览器只需要知道在哪里找到索引文件
/*
* Module dependencies
*/
var express = require('express')
, stylus = require('stylus')
, nib = require('nib')
var logger = require('morgan')
var app = express()
function compile(str, path) {
return stylus(str)
.set('filename', path)
.use(nib())
}
app.set('views', __dirname + '/views')
app.set('view engine', 'jade')
app.use(logger('dev'));
app.use(stylus.middleware(
{ src: __dirname + '/public'
, compile: compile
}
))
app.use(express.static(__dirname + '/public'))
app.get('/', function (req, res) {
res.render('index',{title : 'CheckMe',subheader:'health and fitness for kids',logo:'<img src="images/logo.png" alt="">'})
})
app.listen(3000)
答案 0 :(得分:0)
Express中没有index.html文件。使用单个正斜杠作为您的位置,就像您使用app.get('/', function (req, res) {})
一样定义了您的根页面。没有任何文件名的localhost:3000
应该适合你。
答案 1 :(得分:0)
必须更改虚拟主机代理设置
<VirtualHost 109.74.199.47:80>
ServerAdmin davy.brion@thatextramile.be
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>
http://thatextramile.be/blog/2012/01/hosting-a-node-js-site-through-apache