2016-07-22 6 views
2

小さなオレンジ色でアプリケーションを表現し、私はthis linknodejsは私が「小さなオレンジ」新しいです

以下の小さなオレンジ色で急行アプリケーションを実行しようとしています

/ホーム/ユーザー/ servercode/tmpディレクトリとファイルapp.jsとmyappの /ホーム/ユーザー/ public_htmlの/ clientCode/myappの.htaccessを持つ

/ホーム/ユーザー/ servercode/myappに/ tmpに空restart.txtファイル が含まれています/ home/user/servercode/myapp、私は走った

npm init 
npm install express --save 

これは私のapp.jsですかなり多くの記事で言及リンクの内の1つのと同じ

var express = require('express'); 
var app = express(); 

app.get('/', function (req, res) { 
    res.send('Hello World Express App'); 
}); 

if (typeof(PhusionPassenger) != 'undefined') { 
    console.log('Example app listening with passenger'); 
app.listen('passenger'); 
} else { 
    console.log('Example app listening with 3000'); 
    app.listen(3000); 
} 

の.htaccessは私がmyappのにアクセスしようとすると、私は このエラーを取得できません644許可レベルを持っており、この

PassengerEnabled on 
PassengerAppRoot /home/user/serverCode/myapp 
SetEnv NODE_ENV production 
SetEnv NODE_PATH /usr/lib/node_modules 

が含まれていますGET/myapp/とブラウザコンソールの404

app.jsで以下の内容のエクスプレスなしで通常のnodejsアプリケーションを実行することができました

var http = require('http'); 
var server = http.createServer(function (request, response) { 
    response.writeHead(200, {"Content-Type": "text/plain"}); 
    response.end("Hello World\n"); 
}); 
server.listen(8000); 
console.log("Server running at http://127.0.0.1:8000/"); 

しかし、あなたのようにあなたのアプリケーションにルートを追加する必要があり

答えて

1

実行中の急行アプリを取得することができません:

app.get('/myapp', function(req, res){...}); 
+0

おっとを!ありがとうございました:-) –

関連する問題