This how-to is copied from sathya.de, and i saved it here for personal use.

Setup your own Firefox Sync Server on Debian with Apache2 and MySQL

Install the requirements

apt-get install python-dev mercurial python-virtualenv\
libapache2-mod-wsgi libmysqlclient-dev

Setup Weave

cd /opt
hg clone https://hg.mozilla.org/services/server-full
mv server-full weave
cd weave
make build
chown root:www-data -R /opt/weave
chmod 750 -R /opt/weave/
/opt/weave/bin/easy_install Mysql-Python

Create database

mysql -u root -p
CREATE DATABASE weave;
GRANT ALL PRIVILEGES ON weave.* TO weave IDENTIFIED BY "password";
exit

Configure weave

cp /opt/weave/etc/sync.conf /opt/weave/etc/sync.conf.bak
mv /opt/weave/etc/mysql.conf /opt/weave/etc/sync.conf
nano /opt/weave/etc/sync.conf

Replace

fallback_node = http://localhost:5000/

in the [nodes] section with

fallback_node = https://your-domain.com

Replace

sqluri = mysql://sync:sync@localhost:3306/sync

in the [storage] and [auth] section with

sqluri = mysql://weave:password@localhost:3306/weave

Configure Apache2

Create a new config file

nano /etc/apache2/sites-available/weave

and insert this:

<VirtualHost *:80>
        ServerName your-domain.com
        Redirect / https://your-domain.com
</VirtualHost>
<VirtualHost *:443>
        ServerName your-domain.com
        DocumentRoot /opt/weave

        WSGIProcessGroup sync
        WSGIDaemonProcess sync user=www-data group=www-data processes=2 threads=25
        WSGIPassAuthorization On
        WSGIScriptAlias / /opt/weave/sync.wsgi

        SSLEngine On
        SSLCertificateFile    /etc/apache2/ssl/ssl.crt
        SSLCertificateKeyFile /etc/apache2/ssl/ssl.key

        CustomLog /var/log/apache2/access_sync.log combined
        ErrorLog /var/log/apache2/error_sync.log
        LogLevel warn
</VirtualHost>
<Directory /opt/weave>
        Order deny,allow
        Allow from all
</Directory>

Enable the config file and restart Apache2:

ln -s /etc/apache2/sites-available/weave /etc/apache2/sites-enabled/weave
/etc/init.d/apache2 restart

Check the log file for errors:

tail -f /var/log/apache2/error_sync.log

Updating Weave

cd /opt/weave
hg pull
hg update

Run the last two steps at least twice.

make build