[英]Node js application working on localhost but not working on live server
我是php开发人员
我在apache上设置了虚拟主机
<VirtualHost sub.domain.com:80>
ServerName sub.domain.com
ServerAdmin localhost@domain.com
DocumentRoot /var/www/subpart/html
<Directory /var/www/subpart/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
# Uncomment this directive is you want to see apa$
# default start page (in /apache2-default) when y$
#RedirectMatch ^/$ /apache2-default/
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
这是我的app.js文件
var express = require('express');
var bodyParse = require('body-parser');
var request = require('request');
var app = express();
// var select = require('./select');
app.set('port', 8080);
app.use(bodyParse.urlencoded({extended: false}));
app.use(bodyParse.json());
app.get('/', function(req, res) {
res.send('yelo');
})
app.listen(app.get('port'), function() {
console.log('running on port', app.get('port'))
})
当我运行nodemon app.js
我可以在http:\\\\localhost:8080\\
上访问此应用程序,但是将同一应用程序上载到实时服务器时,行为却很奇怪, https:\\\\sub.domain.com:8080\\
,无法连接错误
我不知道发生了什么,我是一个PHP开发人员,我所要做的只是在服务器上复制并粘贴文件,并且一切正常,但我在nodejs实现方面遇到了很多问题
安装Node.js,并创建如下服务器:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello, world!');
});
server.listen(80, '111.111.111.111');
不要浪费时间了,不要再听那些告诉您使用mod_rewrite再次代理Node.js的人了。
NodeJS不能像mod-perl和mod-php一样用作Apache模块,因此无法在Apache之上运行节点。
我希望此链接能为您提供更多帮助:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.