Hi!
I’m using V5 on the web site, and now testing nodejs.
On the local server after installing the CLI and creating the project, is started “http-server” nodejs module.
Tell me, please, how to install FW7 on a web server, where the “http” nodejs module is used?
Thank you!
I found the answer.
var express = require('express');
var app = express();
app.use('/app', express.static(__dirname + '/app'));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/app/index.html');
});
app.listen(3000);
This means, by default, the server is started using the “http-server” module.
I decided to use the standard “Http” module, it is used by the “ExpressJS” framework.
In the project folder, create the app.js file:
var express = require('express'); /// connect express module
var app = express();
app.use('/app', express.static(__dirname + '/app')); /// setup work directory ( default - www)
app.get('/', function (req, res) {
res.sendFile(__dirname + '/app/index.html'); /// go to index.html
});
app.listen(3000); /// start server nodejs on port 3000
In the project folder create .htaccess file:
PassengerNodejs .local/bin/node /// type your host node path
PassengerAppRoot /mysite.com/project_folder /// project folder with full root path
PassengerAppType node
PassengerStartupFile app.js /// startup file
Set relative paths, edit file routes.js (app/js folder):