Reputation: 143
I am new to "A Small Orange" and I am trying to run an express app in small orange following this link
I first created the following directory structure
/home/user/servercode/myapp with tmp directory and app.js file /home/user/public_html/clientCode/myapp with .htaccess
/home/user/servercode/myapp/tmp contains an empty restart.txt file In /home/user/servercode/myapp, I ran
npm init
npm install express --save
This is my app.js. Pretty much same as the one in the link mentioned in the post
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 has 644 permission level and contains this
PassengerEnabled on
PassengerAppRoot /home/user/serverCode/myapp
SetEnv NODE_ENV production
SetEnv NODE_PATH /usr/lib/node_modules
When I try to access myapp, I get this error Cannot GET /myapp/ and 404 in browser console
I could get a normal nodejs application running without express with the below content in app.js
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/");
But not able to get express app running
Upvotes: 3
Views: 562
Reputation: 3797
You need to add route in you application as :
app.get('/myapp', function(req, res){...});
Upvotes: 2