Recent versions of Firefox include the ability to sync your bookmarks, passwords, preferences, etc. with a remote server. You can choose between a server provided by Mozilla or a custom server.
There seem to be two solutions to deploy a custom server:

Firefox Sync Server requires Python 2.6 and Virtualenv. Since there are no packages for Debian you will have to use make and install some libraries to get it running.
FSyncMS is an PHP-based MySQL/SQLite solution which only requires only a normal webspace and a few steps to setup.

First, get the sourcecode from github https://github.com/balu-/FSyncMS/archive/master.zip and extract it to a directory reachable from the web. Call the setup.php and once finished move it somewhere where it is not callable from the web or delete it. Make sure you provide the correct path in the settings.php (FSYNCMS_ROOT).
If you are using SSL with a self-signed certificate call the url in the browser an accept the security warning from Firefox – otherwise sync will not work.

Next, go to the Firefox Sync settings. If you are already using the official Mozilla Firefox Sync Server unlink your device, your data will stay intact on your local installation of Firefox. Set up sync by creating a new account. Provide an email-adress, secure password and the url to FSyncMS (the url you also defined as FSYNCMS_ROOT in settings.php).
If Firefox says something about a invalid url make again sure that if you are using a self-sigend SSL certificate Firefox accpeted it.
Check the access.log for a request from Firefox – it should call /user/1.0/a via GET and receive a “0” (zero).

To avoid problems regarding HTTP auth and PHP fcgi place a .htaccess in the directory with the following content:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

Thats it, Firefox should now sync your stuff.