Skip to content

How to Host An Instance of Silex

Alex Hoyau edited this page May 6, 2019 · 46 revisions

This page explain how to run Silex yourself, in these contexts:

  • on a server
  • on your local computer as a native app (uses electron)
  • on your local computer built from the sources (multiple methods)
  • on your local computer as an npm dependency in your nodejs project
  • in a Docker container

This is useful to host a public instance of Silex or if you plan to work offline with your local files, or to contribute code to Silex or just to hack into Silex a bit :)

After reading this page you can then read "Silex for hosting providers", especially if your goal is to provide a website builder to your users, white labeled or not, and you want to provide the users with a hosting too, i.e. the user do not use Dropbox or FTP or Github, etc. but your hosting instead. If you plan to customize Silex with your own components, please refer to "Silex Developer Guide"

Feel free to ask any question in the issues here

Host an instance of Silex

If you plan to host Silex for your clients, your users or the community, this section is for you.

If you feel like helping and host an instance of Silex as an alternative to the official Silex site https://editor.silex.me/ please let us know so that we can advertise it to the community.

You will need a nodejs server, which you can setup yourself or host at Gandi or IndieHosters for example.

Download the zip file on github or clone this repository, and then follow the same steps as the developers when they install silex locally on linux - starting at npm install. See instructions bellow.

For the lazy ones, there is the Heroku One-Click Deploy:

Deploy

This will simply bring you to this form and host Silex for free on your heroku account - you can set the env var ENABLE_FTP to true and proceed.

screenshot from 2018-09-05 12-44-39

Concerning environments variables, see the section bellow.

Installation on your local computer

As a native app, Silex desktop version

It works offline and can be downloaded from the releases here or you can build it with npm run build and then start with npm run start:electron (requirement: install Silex locally as explained before)

Silex desktop version

As a web app, Silex web version

This is for developers mostly, since our beloved designers can use the online version.

Developers you can clone this repository and start Silex, with nodejs. To do this you can use just nodejs or npm, see instructions bellow.

Recommended method: with npm

Prerequisite :

$ npm install -g silex-website-builder
$ silex

Docker

Prerequisite :

Build the docker image for Silex

$ docker build -t silex-image .
$ docker run -p 6805:6805 -t silex-image

Open http://localhost:6805/ and you are ready!

The default env vars can be overriden using the -e option in docker run, see the section about env vars bellow

local installation on linux or macos or cloud9

Prerequisite:

Clone this repository, and do not forget the sub modules (cloud-explorer and unifile)

$ git clone --depth 10 https://github.com/silexlabs/Silex.git

Install all needed modules and build the assets

$ npm install
$ npm run build

note #1: Install as a non root user with write/read access to silex files and folders

note #2: If you have errors and it is about node-sass, try installing node-sass (npm install node-sass) before installing silex again

Start the server and then open http://localhost:6805/ - note that the port is 6805, which is easy to remember, since it is the date of sexual revolution started in paris france 8-)

$ npm start

Note for cloud9 users: you may want to activate python with this command:

$ nada-nix install python

And finally, take a look at the "available commands" section bellow

local installation on Windows

instructions provided by Régis RIGAUD:)

Prerequisite:

Installation of Silex:

Start Silex:

  • Launch Silex from a command prompt (Silex's Directory): npm start
  • Open your favorite browser on http://localhost:6805/ and ENJOY !!!
  • also take a look at the "available commands" section bellow

Available commands when silex is installed locally

If you develop or debug Silex, these npm scripts can be used with npm (they are defined in the file package.json)

  • $ npm start will start the server
  • $ npm run start:debug will start the server in debug mode (no error catchall, enable local service to use local file system as a storage)
  • $ npm run build will build the client side code (html, css, js), ready for production
  • $ npm run build:server:debug watch the src/server source folder and build the server nodejs app (from typescript source files)
  • $ npm run build:client:debug will watch the src/client source folder and build the client app (typescript)
  • $ npm run start:electron start the electron app / Silex desktop version

environment variables

Silex config can be overriden with env vars or before passing the config to Silex

Here are the env vars:

  • SERVER_URL base URL of your Silex instance, passed to OAuth services like github si they can come back to you with a token
  • PORT, optional, default: 6805, used here in the code
  • SSL_PORT, optional, default: to 443, used here in the code
  • SILEX_FORCE_HTTPS, optional used here in the code to force https/ssl (default is false)
  • SILEX_SSL_PRIVATE_KEY, optional (see ssl section bellow), used here in this source file
  • SILEX_SSL_CERTIFICATE, optional (see ssl section bellow), used here in this source file
  • SILEX_FORCE_HTTPS_TRUST_XFP_HEADER: optional, useful only if SILEX_FORCE_HTTPS is true, see the param trustXFPHeader in this doc
  • SILEX_SESSION_SECRET, optional, session secret, see the cookie-session module for more info (used in this source file)
  • SILEX_DEBUG, optional, default: false, when true this will enable the service "www" (storage on the local server in www/) with login admin and pass admin
  • GITHUB_CLIENT_ID and GITHUB_CLIENT_SECRET: optional, to activate github service, you need to create a github app to get these info (create a github app to get those)
  • DROPBOX_CLIENT_ID and DROPBOX_CLIENT_SECRET: optional, this will activate Dropbox service, you need to create a Dropbox app on developers.dropbox.com
  • ENABLE_FTP, ENABLE_SFTP, ENABLE_WEBDAV, ENABLE_FS: optional, used to activate the corresponding services
  • SILEX_ELECTRON: this is set by Silex electron app, in order to activate the fs service and access your file system from within Silex
  • SKIP_HOSTING_SELECTION: [Optional] Skip the hosting selection dialog. This is a publication setting. Set this value to true if you want the user to be forced to publish in the first hosting provider you enable. This is useful when you provide hosting to your users.
  • ENABLE_HOSTING_GH_PAGES: [Optional] Enable Github Pages hosting provider. This is a publication setting. Set this value to true if you want your users to be able to publish to Github Pages.
  • ENABLE_HOSTING_UNIFILE: [Optional] default is 'true'] Enable the user to select a folder to publish to. This is a publication setting. Set this value to false if you do not want your users to be able to manually select a folder when they try to publsh a website.
  • ENABLE_HOSTING_JEKYLL: [Optional] Enable Jekyll hosting provider. This is a publication setting. Set this value to true if you want the user to be able to publish their website as a template for a Jekyll website

Tip: for your tests on localhost, you can use these test apps

$ export DROPBOX_CLIENT_ID=ckixgyo62obeo05
$ export DROPBOX_CLIENT_SECRET=ptg6u5iw7gs6r6o
$ export GITHUB_CLIENT_ID=f124e4148bf9d633d58b
$ export GITHUB_CLIENT_SECRET=1a8fcb93d5d0786eb0a16d81e8c118ce03eefece

enable https / SSL

When you start Silex, it looks for the environment variables SILEX_SSL_PRIVATE_KEY and SILEX_SSL_CERTIFICATE. If they are present, it enables SSL.

SILEX_SSL_PRIVATE_KEY is expected to be the path to a .key file, and SILEX_SSL_CERTIFICATE the path to a .crt.

WARNING: Support for Silex v2 has stopped. Try Silex v3 alpha, Read about it, Subscribe to the newsletter

Clone this wiki locally