title | excerpt | updated |
---|---|---|
Install Express on your POWER web hosting plan |
Find out how to install Express on your POWER web hosting plan |
2021-02-04 |
You've subscribed to a Web POWER web hosting plan to deploy Node.js applications, and you want to begin developing your project using Express{.external}.
This guide will explain how to deploy a simple Hello World server on Express.
Find out how to install Express on your POWER web hosting plan.
- a Node.js POWER web hosting plan
- access to the OVHcloud Control Panel
If you have just started to use your Web POWER web hosting plan, we suggest to have a look at our Getting started with a POWER web hosting plan guide before going further.
Let's suppose you have the default configuration for Node.js hosting:
- Runtime: nodejs 14
- Entrypoint: index.js
- DocumentRoot: www
[!primary]
To verify your configuration, you can use the Retrieve active configuration API endpoint.
Connect via SSH to your POWER web hosting, and install Express using npm
:
npm install express --save
Then go to the www
folder and create an index.js
file there:
index.js
const express = require('express');
const port = 3000;
const msg = `Hello World from NodeJS ${process.version}\n`;
const app = express();app.get('/', function (req, res) {
res.send(msg);
});
app.listen(port);
Restart your instance and your Express Hello World will be online.
Terminal output:
~/www $ cd www
~/www $ node -v
v14.13.0
~/www $ npm install express --save
~/www $ vi index.js
const express = require('express');
const port = 3000;
const msg = `Hello World from NodeJS ${process.version}\n`;
const app = express();app.get('/', function (req, res) {
res.send(msg);
});
app.listen(port);
~/www $ mkdir -p tmp
~/www $ touch tmp/restart.txt
Join our community of users on https://community.ovh.com/en/.
Join our Discord on our web-hosting-power channel to discuss directly with the team and other users of this lab.