Skip to content

Running from source with Node.js

Run Silex directly with Node.js, for self-hosting or for contributing. This gives you control over the process manager (systemd, PM2, supervisor) and the configuration.

Coming from the old multi-repo layout?

If you have a clone, branch or pull request from before Silex became a monorepo, read Migrating from the old repos first — don't git pull an old clone, the default branch was repointed to an unrelated history.

Overview

Silex is a monorepo and the app is a single Node.js package. There is no @silexlabs/silex-platform package and no global command line tool anymore. You self-host by cloning the repository, building it once, and running the server.

The default configuration is the full SaaS: multi-site dashboard, onboarding, and storage/hosting connectors. The GrapesJS plugins are built into the editor.

Prerequisites

  • Node.js 20 or later
  • pnpm (the project uses pnpm via corepack: corepack enable)
  • Git

Setup from source

git clone --recurse-submodules https://github.com/silexlabs/Silex.git
cd Silex
pnpm install
pnpm build
pnpm start

The server starts at http://localhost:6805.

--recurse-submodules pulls the dashboard content, which the full SaaS serves. If you already cloned without it:

git submodule update --init --recursive

Want to contribute? After cloning, check the good first issues. See also Contribute to Silex.

Configuration with a .env file

Create a .env file in the repository root. Silex reads it on startup:

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

Then pnpm start. The server uses the values from .env.

Key environment variables

Variable Default Purpose
SILEX_PORT 6805 Port to listen on
SILEX_HOST localhost Hostname (use 0.0.0.0 for remote access)
SILEX_PROTOCOL http Protocol before a reverse proxy
SILEX_URL http://localhost:6805 Public URL users visit
SILEX_SESSION_SECRET (none) Random key for session encryption
SILEX_SERVER_CONFIG (built-in SaaS config) Path to a custom server config file
SILEX_CLIENT_CONFIG (built-in SaaS config) Path to a custom client config file
STORAGE_CONNECTORS (set by config) Comma-separated: fs, gitlab, ftp
HOSTING_CONNECTORS (set by config) Comma-separated: fs, gitlab, ftp, download
SILEX_FS_ROOT ./silex/storage Path for the filesystem storage connector
SILEX_FS_HOSTING_ROOT ./silex/hosting Path for the filesystem hosting connector

See docker.md for the full list, and Server configuration for the config API.

Remote access

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

SILEX_HOST=0.0.0.0 pnpm start

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

Running as a system service

After pnpm build, the server entry point is dist/server/server/ and you start it with pnpm start (which runs node dist/server/server/).

With systemd (Linux)

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

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

[Service]
Type=simple
User=silex
WorkingDirectory=/opt/silex
ExecStart=/usr/bin/node /opt/silex/dist/server/server/
Restart=on-failure
RestartSec=10

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

[Install]
WantedBy=multi-user.target

This assumes you cloned and built Silex in /opt/silex. Create the user and enable the service:

sudo useradd -m -s /usr/sbin/nologin silex
sudo systemctl daemon-reload
sudo systemctl enable --now silex
sudo journalctl -u silex -f

With PM2

npm install -g pm2

Create ecosystem.config.js in the repository root:

module.exports = {
  apps: [
    {
      name: 'silex',
      script: 'dist/server/server/index.js',
      env: {
        SILEX_PORT: 6805,
        SILEX_URL: 'https://silex.example.com',
        SILEX_SESSION_SECRET: 'your-random-secret',
        STORAGE_CONNECTORS: 'fs',
        HOSTING_CONNECTORS: 'fs,download',
      },
    },
  ],
}
pm2 start ecosystem.config.js
pm2 save
pm2 startup

Custom server config

For most setups, environment variables are enough (connectors, ports, URLs). If you need to change server behavior in code, point SILEX_SERVER_CONFIG to a JavaScript file:

SILEX_SERVER_CONFIG=./my-config.js pnpm start

See Server configuration for the ServerConfig API and connector setup. The built-in SaaS config lives in server/deploy/ in the repository and is a good reference.

Debugging

SILEX_DEBUG=true pnpm start

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

Troubleshooting

Port already in use

SILEX_PORT=8080 pnpm start

Or find and stop the process using the port:

lsof -i :6805
kill -9 <PID>

Module not found, or stale build

Reinstall and rebuild:

pnpm install
pnpm build

See also

Edit this page on GitLab