跳到主要內容

Setup on Ubuntu + FNM

Ubuntu is a popular Linux distribution loved by the developer community, Blocklet Server can run on it with the following steps.

Run as root user with Nginx

Following are the steps to setup your blocklet server on Ubuntu as root (not recommended):

Setup Node.js with fnm

fnm is another awesome Node.js version manager, just like nvm.

javascript
root@fnm:~$ curl -fsSL https://fnm.vercel.app/install | bash
root@fnm:~$ source /root/.bashrc
root@fnm:~$ fnm install v18

Setup nginx latest version

Please refer to the nginx official documentation to get the latest version of nginx on Ubuntu, otherwise, your nginx may not work for blocklet server.

Verify your environment

javascript
root@fnm:~$ node --version
// v18.19.0, or above version
root@fnm:~$ nginx -version
// nginx version: nginx/1.24.0

Install blocklet server

javascript
root@fnm:~$ npm install -g @blocklet/cli

Get your server up and running

javascript
root@fnm:~$ blocklet server init -f
root@fnm:~$ blocklet server start

Run as non-root user with Nginx

If you want to run your blocklet server as non-root (recommended), refer to the following steps:

Setup Node.js with fnm

Since fnm installs node.js on a per-user basis, if you have done this as root, you should do it again as ubuntu

javascript
ubuntu@fnm:~$ curl -fsSL https://fnm.vercel.app/install | bash
ubuntu@fnm:~$ source /root/.bashrc
ubuntu@fnm:~$ fnm install v18

Setup nginx latest version

Just like the root user instructions, you must complete this step as the root user.

Setup permissions for node.js and nginx

If 80/443 ports are available for blocklet server, all access URLs are clean without annoying ports, however, non-root users on ubuntu can not listen on 80/443 ports by default, but you allow nginx to listen on 80/443 port with following commands:

javascript
ubuntu@fnm:~$ sudo apt-get install libcap2-bin
ubuntu@fnm:~$ sudo setcap cap_net_bind_service=+ep /usr/sbin/nginx

Verify your environment

javascript
ubuntu@fnm:~$ node --version
// v18.19.0, or above version
ubuntu@fnm:~$ nginx -version
// nginx version: nginx/1.24.0

Install blocklet server

javascript
ubuntu@fnm:~$ npm install -g @blocklet/cli

Get your server up and running

javascript
ubuntu@fnm:~$ blocklet server init -f
ubuntu@fnm:~$ blocklet server start

Run as non-root user without Nginx

It's recommended that you use nginx as the routing engine for blocklet server when running it for production purposes, however you can run blocklet-server as non-root user without nginx if you want to evaluate it.

Setup Node.js with fnm

Since fnm installs node.js on a per-user basis, if you have done this as root, you should do it again as ubuntu

javascript
ubuntu@fnm:~$ curl -fsSL https://fnm.vercel.app/install | bash
ubuntu@fnm:~$ source /root/.bashrc
ubuntu@fnm:~$ fnm install v18

Setup permissions for node.js

If 80/443 ports are available for blocklet server, all access URLs are clean without annoying ports, however, non-root users on ubuntu can not listen on 80/443 ports by default, but you allow node.js to listen on 80/443 ports with following commands:

javascript
ubuntu@fnm:~$ sudo apt-get install libcap2-bin
ubuntu@fnm:~$ sudo setcap cap_net_bind_service=+ep `which node`

Verify your environment

javascript
ubuntu@fnm:~$ node --version
// v18.19.0, or above version

Install blocklet server

javascript
ubuntu@fnm:~$ npm install -g @blocklet/cli

Get your server up and running

javascript
ubuntu@fnm:~$ blocklet server init -f
ubuntu@fnm:~$ blocklet server start