# General Setup

## $LJHOME Environment Variable

Be aware that nearly all LiveJournal code depends on the `$LJHOME` environment variable being set to the top-level directory that LiveJournal is installed at.

has the necessary directives to make sure the web code always has $LJHOME set, but if you're running LJ maintenance commands from a terminal, you'll need to make sure `$LJHOME` is set for yourself.

For example, we'll assume that you've installed LiveJournal on an operating system using the Bourne Shell: The easiest way to set `$LJHOME` is to put the following in your `~/.bash_profile`:

    LJHOME=/home/lj; export LJHOME

To test that it's set:

    $ . ~/.bash_profile
    $ echo $LJHOME

If the above was successful, it should print out `/home/lj` (or whatever the value of `$LJHOME` may be).

### Other shells

If you use another shell interface, you might be able to see what it reads on start-up by looking for the file: `~/.profile`. Please refer to the documentation provided with your shell, which can usually be found by typing:

    $ help

## Installing the files

The typical directory to install LiveJournal is `/home/lj`, but it is not a requirement at all. To ease documentation, we'll assume that you'll want to install in that directory. We'll also assume you'll be using user `lj`, but that also doesn't matter at all. Feel free to install wherever and as whoever … there shouldn't be any problems.

### Prerequisite: `$LJHOME`

Before you install using either method, you should create the directory where your LiveJournal installation will reside. This needs to be the same directory that the environment variable `$LJHOME` is set to, otherwise your installation will not work properly. Consult for more information on setting `$LJHOME`.

### Creating the `$LJHOME` directory:

    # mkdir /home/lj
    # chown lj.lj /home/lj

### Using Tarballs

LiveJournal maintains the server code in `tar.gz` (tarball) format, which can be downloaded from: . The tarballs are labelled by date, so be sure to grab the latest one.

Untar the tarball from the `$LJHOME` directory, and then run the provided installation script, `bootstrap.pl`.

### Tarball Install:

    $ cd $LJHOME
    $ tar zxvf LiveJournal-YYYYMMDDNN.tar.gz
    $ ./bootstrap.pl

### Using CVS

Bleeding edge releases of the code can be found in CVS at the CVS server: cvs.livejournal.org.

Installing and updating LiveJournal from CVS is not guaranteed as stable as tarball releases. If you need a more stable release, you're better off using the packaged tarballs as mentioned above.

### CVS Install:

    $ mkdir $LJHOME/cvs
    $ cd $LJHOME/cvs
    $ cvs -z3 -d:pserver:anonymous@cvs.livejournal.org:/home/cvslj co livejournal
    $ cvs -z3 -d:pserver:anonymous@danga.com:/home/cvspub co wcmtools bml
    $ wcmtools/bin/multicvs.pl --conf=livejournal/cvs/multicvs.conf --init

That last command will copy everything from the CVS directory over to `$LJHOME`, the live area.

Having two copies of the code laying around may not make sense now, but it will later when we write the docs to explain how to run a heavily-customized version of the site and still stay up-to-date with the mainstream CVS. (FIXME: write/link that section)