Skip to content

Running from Node.js

Install and run Silex from npm, source code, or npx for development and self-hosted setups.

Overview

Instead of Docker, you can run Silex directly on your server using Node.js. This gives you more control over the process manager (systemd, PM2, supervisor) and lets you customize the startup script.

Three installation methods:

  1. npm package — Recommended for deployment
  2. npx — Quick testing without installation
  3. Source code — For development and contributing

Prerequisites

  • Node.js 18 or later
  • npm 8 or later (comes with Node)
  • Git (if cloning from source)

Setup from npm

1. Install globally or locally

Global install:

npm install -g @silexlabs/silex-platform

Or per-project:

mkdir my-silex && cd my-silex
npm install @silexlabs/silex-platform

2. Create .env file

cat > .env << EOF
SILEX_SESSION_SECRET=$(openssl rand -base64 32)
SILEX_PORT=6805
SILEX_URL=http://localhost:6805
STORAGE_CONNECTORS=fs
HOSTING_CONNECTORS=fs,download
SILEX_FS_ROOT=./silex/storage
SILEX_FS_HOSTING_ROOT=./silex/hosting
EOF

3. Start the server

With global install:

silex-platform

With local install:

npx @silexlabs/silex-platform

Or add to package.json:

{
  "scripts": {
    "start": "silex-platform"
  }
}

Then run:

npm start

The server starts at the URL in your .env file (default: http://localhost:6805).

Quick test with npx

No installation needed:

npx @silexlabs/silex-platform

This downloads, installs, and runs the latest version. The server listens on port 6805 by default.

Stop with Ctrl+C. All data is stored in ./silex/storage and ./silex/hosting in your current directory.

Setup from source code

For development or building plugins:

git clone https://github.com/silexlabs/Silex.git
cd Silex
npm install
npm run build

Run the dev server:

cd packages/silex-platform
npm start

Or run from the monorepo root:

npm -w packages/silex-platform start

Want to contribute? After cloning, check GitHub Issues for beginner-friendly tasks. See also Contribute to Silex.

Environment variables

All variables can be set in a .env file or passed as command-line arguments:

SILEX_PORT=6805 npx @silexlabs/silex-platform

See docker.md#environment-variables for the full list.

Key variables for Node setup:

Variable Default Purpose
SILEX_PORT 6805 Port to listen on
SILEX_HOST localhost Hostname (0.0.0.0 for remote access)
SILEX_URL http://localhost:6805 Public URL users visit
SILEX_SESSION_SECRET (none) Random key for session encryption
SILEX_SERVER_CONFIG .silex.js Path to config file (relative to cwd)
SILEX_CLIENT_CONFIG client-config.js Path to client config file

Setting SILEX_HOST for remote access

By default, the server only listens on localhost. To allow remote connections:

SILEX_HOST=0.0.0.0 npx @silexlabs/silex-platform

Then access from another machine: http://your-server-ip:6805

Running as a system service

With systemd (Linux)

Create /etc/systemd/system/silex.service:

[Unit]
Description=Silex Website Builder
After=network.target

[Service]
Type=simple
User=silex
WorkingDirectory=/home/silex/silex-instance
ExecStart=/usr/bin/node /usr/bin/silex-platform
Restart=on-failure
RestartSec=10

# Environment
Environment="SILEX_PORT=6805"
Environment="SILEX_URL=https://silex.example.com"
Environment="SILEX_SESSION_SECRET=your-random-secret"

[Install]
WantedBy=multi-user.target

Create the silex user:

sudo useradd -m -s /usr/sbin/nologin silex
sudo mkdir -p /home/silex/silex-instance
sudo chown silex:silex /home/silex/silex-instance

Enable and start:

sudo systemctl daemon-reload
sudo systemctl enable silex
sudo systemctl start silex

Check status:

sudo systemctl status silex
sudo journalctl -u silex -f

With PM2

Install PM2:

npm install -g pm2

Create ecosystem.config.js in your Silex instance directory:

module.exports = {
  apps: [
    {
      name: 'silex',
      script: 'silex-platform',
      instances: 1,
      exec_mode: 'cluster',
      env: {
        SILEX_PORT: 6805,
        SILEX_URL: 'https://silex.example.com',
        SILEX_SESSION_SECRET: 'your-random-secret',
        STORAGE_CONNECTORS: 'fs',
        HOSTING_CONNECTORS: 'fs,download',
      },
    },
  ],
}

Start:

pm2 start ecosystem.config.js
pm2 save
pm2 startup

View logs:

pm2 logs silex

Custom server config

You can modify server behavior with a config file:

SILEX_SERVER_CONFIG=./my-config.js npx @silexlabs/silex-platform

Create my-config.js:

const GitlabConnector = require('@silexlabs/silex-plugins').GitlabConnector

module.exports = async function (config) {
  // Add a storage connector
  config.addStorageConnector(
    new GitlabConnector(config, {
      clientId: process.env.GITLAB_CLIENT_ID,
      clientSecret: process.env.GITLAB_CLIENT_SECRET,
      domain: process.env.GITLAB_DOMAIN,
    })
  )
}

See Server configuration for the full ServerConfig API.

Debugging

Enable debug mode:

SILEX_DEBUG=true npx @silexlabs/silex-platform

This reloads the config file on each request and logs detailed startup info.

Troubleshooting

Port already in use

Change the port:

SILEX_PORT=8080 npx @silexlabs/silex-platform

Or find and kill the process using port 6805:

lsof -i :6805
kill -9 <PID>

EACCES permission denied

npm tried to install globally without sudo. Fix npm permissions:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH

Then add to your shell profile (.bashrc, .zshrc):

export PATH=~/.npm-global/bin:$PATH

Module not found errors

Reinstall dependencies:

npm install
npm run build

See also

Edit this page on GitLab