How to set-up a SiteFusion server

Here we will try to provide you with all information needed to setup a
SiteFusion server and connect to it using the SiteFusion client.

Requirements

Make sure these packages are installed: PHP5 (at least 5.2.4, or 5.3),
including the CLI (command line interface), MySQL and Apache2 (although
other webserver software will probably do just fine). The SiteFusion daemon was written for Linux and Unix(like) POSIX operating systems. Mac OS X has been proven fine as well, but the version of PHP supplied with Mac OS X does not include some of the modules necessary to run SiteFusion. Equally, default linux repository installations often don't include these modules, so you might have to add them separately. On Mac OS X, this is only possible if you replace the default PHP installation with the one on MacPorts. Here's a good tutorial on how to install an apache/php/mysql setup through MacPorts. For more information on installing Apache, MySQL, PHP and PHP modules on your linux setup, please refer to the documentation of your specific distribution or portage software. The necessary PHP modules are:

json (usually part of the default PHP installation these days)

sockets

posix

pcntl

You can check which PHP modules are installed by typing in the shell:

$ php -m

To check for the required modules easily, use this line:

$ php -m | grep -e "json\|sockets\|posix\|pcntl"

It should show all four module names, if anything is missing it's not installed.

Installation

Install SiteFusion by downloading a release package or by using Git. Where you see 5.x.x below, replace for the version of your choice.

Git

$ git clone https://github.com/sitefusion/server.git sitefusion

PackageIn the case of a package, download it and extract:

$ tar zxvf SiteFusion-5.x.x.tar.gz$ mv SiteFusion-5.x.x sitefusion

In my case, the user is called 'dev' and I extracted the package to /home/dev/sitefusion, although a more suitable location for production environments might be /usr/local/sitefusion or something like that, depending on conventions on your operating system or distribution.

Setup

After extracting we need to edit two configuration files. They can be found in the 'conf' directory, named daemon.conf.example and webfrontend.conf.example. If this is your first installation and you don't have custom config files yet, copy the example files to remove the .example part:

The file daemon.conf holds the configuration for the SiteFusion daemon.

There are basically two scenarios for running the daemon:

Start as root (default and recommended): Leave the runtimeDirectory and logfile locations to the default system locations,
set changeIdentity to TRUE and fill in a safe user (systemUser) and group (systemGroup) for the
daemon to change to (like a separate user owning the sitefusion
installation directory, or like the nobody or apache/www-data users who
should have at least reading permissions in the sitefusion installation
directory). Then start as root. The daemon will then change to the safe
user and automatically make sure it can use the log and runtime
locations as that user.

Start as unpriviledged user: Create new runtime and log directories
in the sitefusion installation directory (mkdir run && mkdir
log) and change the runtimeDirectory and logfile configuration options to have them point to these
locations. Set the changeIdentity option to FALSE. Then start as the
unpriviledged user.

Note that in neither scenario the daemon
will be running as root. In the first it will only start as root and
then change to the safe user as soon as runtime and log locations are
setup correctly.

Make sure the logfile and runtimeDirectory configuration settings contain a path to a logfile (doesn't have to exist yet) and a path to a directory respectively. When you're done editing save and close the file. The second file you
have to edit is webfrontend.conf. This one concerns the communication
between the webserver and the daemon.

Note: From SiteFusion Server 6.0 onward, the default setup is to use sqlite3 instead of mysql for the database used by the daemon to store process and service information. Use the field databaseDSN to set the database protocol, host and credentials instead of using the deprecated fields databaseHost, databaseUsername and databasePassword. The default databaseDSN will use the pre-packaged sqlite3 database in the 'db' directory.

When using MySQL as the daemon database back-end

When MySQL is used, we have to create the sitefusion database and tables. SiteFusion uses the database to hold its process information and job/service configuration. In order to do this, change to the install/ directory. Run the script with:

$ php sfdatabase

Again, you have to provide the ip, username and password for your MySQL server. The script creates the database and tables:

After filling the database, it's time to set up permissions for the sitefusion dir. You should give the www and conf subdirectories global read and execute permissions (chmod 755) so the webserver can run the webfrontend PHP files. Run this command from the sitefusion installation directory:

$ chmod -R 755 www conf

The rest of the installation directory needs to have the same permissions if you plan to run the daemon as root and have it change to a safe user. At least it needs to be readable by the user running the daemon.

The last thing you have to to is add an alias or vhost to the webserver configuration and point it to the SiteFusion www directory. In the case of apache, either add the following configuration to an existing vhost or create a new one.

Notice that you have to point to the www directory in the location you extracted the SiteFusion files to earlier.

After this, reload or restart the webserver to activate your new alias. You can test if things are working by opening a browser and navigating
to http://yourip/sitefusion/login.php. If you don't get a 404 or 403
error, you will be fine. Depending on your browser you should see a piece of JSON text indicating an input error, or a download dialog for login.php resulting in a textfile with the same contents.

Getting started up

Now start the SiteFusion daemon application. When running for the first time add the -f option to the shell command, the daemon will stay
in foreground and you will be able to read error messages. Navigate to the sitefusion dir and execute either as root (or through sudo) if changeIdentity is on, or as the safe
user:

$ php sitefusiond -f

Possible options are:-d debug mode (same as setting the debug option in daemon.conf to TRUE)-f stay in foreground (don't daemonize, same as setting the daemonize option in daemon.conf to FALSE)

If no errors occur, you can shut down the daemon by pressing Ctrl+C and restart without the -d and -f options for production environments. If you are planning to debug instead of running production
applications, you can choose to run with the option -d. Debug information is then made available through the log, and the debugger in SiteFusion Admin will be enabled to connect to running processes.

The server setup is now completed. Assuming
you've set up the client (if not, read here), it
will prompt you for a number of options. Server URL is the URL of the
server we just set up. So http://yourip/sitefusion. The example
application is the administration application so in the application
field fill in 'sitefusion/admin'. You can leave arguments empty.
Finally, the default username is 'admin' and the password is 'secret'.
This password can be changed by editing the file sfadminPasswd.php.inc
in the app/sitefusion/ directory.

Troubleshooting

Most error messages will be reasonably clear as to what's causing the problem. If you get errors concerning undefined functions, you're probably missing one of the required PHP modules as listed in the Requirements section above.

If the daemon hangs at 'Opening main server socket...', there are a few possible explainations. Either the port is already in use by another program (the default port is 5173), in which case you should change the designated port number in both configuration files in the conf directory. It's also possible that a sitefusion daemon is still running and should be shut down through SiteFusion Admin. If for some reason it became inaccessible, it can be killed. You can check this by running from shell:

$ ps uax | grep sitefusion

If the error refers to the logfile path or the runtime directory path, make sure that these paths are correct and writable to the user running the daemon.

update 32-9-09: I've added runtimeDirectory as a necessary change since it needs to be changed according to the distribution your server is running.

Tom | 23-09-2009 14:29

SiteFusion for windows?

Alexis Lara | 01-06-2010 16:21

Currently the SiteFusion daemon doesn't work on non-POSIX systems, however you could simply run a virtual machine with Linux to use SiteFusion.