Skip to content

Host a static site with Express

Check your server's IP and port number#

Visit the client portal. On the My Services page, click your server name to view its IP and port. We'll use them later.

Create a JS file#

Next, in the control panel, click the Files tab and New File.

Copy and paste the codes below. Replace the port number with your server's port.

1
2
3
4
5
6
7
8
9
const express = require('express')
const app = express()
const port = 27188 // REPLACE THE PORT!!

app.use(express.static('public'))

app.listen(port, '0.0.0.0', () => {
  console.log(`Express listening on port ${port}`)
})

Note

If you are a beginner to Express, learn more about it at their official docs.

After that, click Create File and set the filename to index.js.

Install Express#

Start the server and enable the Shell Access Mode.

Run this command to install Express:

npm i express

Download a Bootstrap 5 website template#

In the Shell Access Mode, run the following commands:

1
2
3
4
5
wget -nv -O website.zip https://github.com/startbootstrap/startbootstrap-bare/archive/gh-pages.zip
mkdir -p public
unzip -q website.zip -d ./public
mv ./public/startbootstrap-bare-gh-pages/* ./public
rmdir ./public/startbootstrap-bare-gh-pages

Now, you can exit shell access. Your web app will start automatically.

Visit the website#

Once your express app is online, you can visit your website with the IP and port number you saw in the client portal (e.g. 216.27.10.96:27188) in your browser. Do not use our node hostname (e.g. free4.alaister.net:27188), otherwise you will see an SSL error.

Done! You have now created a static site.

Please read our custom domain guide.


Last update: March 3, 2022
Back to top