6. Set up LJ <=> FotoBilder Integration

FotoBilder has its own, separate, manual[o] and codebase[o]. Its codebase is being integrated into LiveJournal; it will be discontinued as a separate project eventually. If you do want to install it, you also need to set up Perlbal.

First, make sure the necessary directories are in place. You also need to set up FBHOME. You can place this into your startup files, as with Section 1, “$LJHOME Environment Variable”

$ cd $LJHOME
$ mkdir fb
$ export FBHOME=/home/lj/fb
$ mkdir fb/cvs
$ cd fb/cvs

Next, get the code from the repository:

$ svn co http://code.sixapart.com/svn/fotobilder/trunk fb
$ /home/lj/bin/vcv --conf=fb/cvs/multicvs.conf --checkout
$ /home/lj/bin/vcv --conf=fb/cvs/multicvs.conf -s
$ cd ../
$ ./bin/cvsreport.pl -s

Now set up the database:

$ mysql -uroot -p
mysql> CREATE DATABASE ON fotobilder.* TO 
     > fb@'localhost' IDENTIFIED BY 'fbpass';
     > \q

Run bin/checkconfig.pl. If it reports any missing packages, install them then re-run that command again.

Now you need to copy across the configuration file and update the database.

$ cp doc/fbconfig.pl etc/
$ mkdir logs
$ ./bin/upgrading/update-db.pl -r -p
$ bin/upgrading/texttool.pl load en en_YS

You can make the following updates in ljconfig.pl to integrate the two installations:

{
    %FOTOBILDER_IP = (
            '127.0.0.1' => 1,
            '192.170.2.5' => 1, # change for your IP
            );

    $FB_DOMAIN = "pics.$DOMAIN";
    $FB_SITEROOT = "http://$FB_DOMAIN";

    # referrer domain names that LiveJournal will redirect
    # users to after login. Should usually match $LJ::FB_DOMAIN:
    $REDIRECT_ALLOWED{$FB_DOMAIN} = 1; 

    $REDIRECT_ALLOWED{$FB_SITEROOT} = 1;

    $REDIRECT_ALLOWED{'127.0.0.1'} = 1;
    $REDIRECT_ALLOWED{'192.170.2.5'} = 1;     # change for your IP
    # $FOTOBILDER_IP{'127.0.0.1'} = 1;        # FotoBilder IP address(es) trusted to make XML-RPC calls
}

Your $LJHOME/fb/etc/fbconfig.pl needs the following corresponding settings:

$AUTH_DOMAIN{1} = [ "LiveJournal", {                     # auth module name. do not change to your sitename.
    'ljhost' => '127.0.0.1',                             # this should point to your server
    'domain' => [ 'yourdomain.example.org' ],            # change to your domain / dev domain
    'vhost' => [ 'pics.yourdomain.example.org' ],        # change to your domain / dev domain
    # allowed_ips  => [ 127.0.0.1, 192.168.0.1 ],        # trusted IP addresses LJ server uses for XML-RPC calls
}];

The $FB::AUTH_DOMAIN{1} variable controls cross-authentication between LiveJournal/FotoBilder. The fbconfig.pl example above uses the “LiveJournal” plugin, as distinct from the “LJcom” plugin, which is used for the site-specific non-GPL ljcom code and its FotoBilder counterpart picpix.

The relevant usercaps are:

fb_account: determines whether a LiveJournal user can have a FotoBilder account auto-created for them on the fly.
fb_can_upload: determines whether the user will have the “can_upload” dcap sent in “get_user_infoXML-RPC requests from LiveJournal to FotoBilder. For the LJCOM auth module, this is what determines when an account enters/leaves a downgraded state.
fb_allstyles: determines whether the user can use all the available styles.

Add the following, amending as necessary, to your /etc/perlbal/perlbal.conf file:

# In service selector (ss) section:
  VHOST pics.EXAMPLEHOSTNAME.lj = fotobilder
  VHOST www.EXAMPLEHOSTNAME.lj;using:pics.EXAMPLEHOSTNAME.lj = fotobilder

CREATE POOL fb_pool
  POOL fb_pool ADD 127.0.0.1:8082

CREATE SERVICE fotobilder
  SET role = reverse_proxy
  SET pool = fb_pool
  SET persist_backend = on
  SET max_backend_uses = 10
  SET backend_persist_cache = 2
  SET verify_backend = on
  SET enable_reproxy = on
  SET upload_status_listeners = 127.0.0.1:7002
ENABLE fotobilder

Make the following updates in /etc/apache-perl/httpd.conf:

Instead of Port, use:

Listen *:8081 # LiveJournal
Listen *:8082 # FotoBilder

Add the following, amending as necessary:

<VirtualHost *:8082>
ServerName   pics.yourdomain.example.org
PerlSetEnv   LJHOME /home/lj
PerlSetEnv   FBHOME /home/lj/fb
PerlRequire  /home/lj/fb/lib/startup.pl
</VirtualHost>

You might also need to add new spool directories:

$ cd $LJHOME
$ mkdir fb/var/picroot/1/spool