# Apache

Apache is the most popular HTTP server software used today, and it's completely free. We use Apache for our projects because there is simply no equivalent. In this chapter we'll briefly explain how to setup and configure an Apache installation.

## Installation

### mod_perl

LiveJournal in the past has been server API agnostic, working on either FastCGI or mod_perl, but we've dropped FastCGI support, as there's really no need to maintain it anymore. LiveJournal now solely requires mod_perl; seeing as how it's everywhere and well supported, and you might already have it on your machine. If not, you can read up on the official installation docs located at

We've found that more people have success when mod_perl is statically linked, rather than using a DSO. Consult mod_perl Installation User Guide: When DSO Can Be Used for more information.

#### Debian

Typically, if you already have a working apache installation in Debian and would like to install mod_perl support, then installing the package `libapache-mod-perl` should suit your needs. Otherwise, you should install the package `apache-perl`.

### Apache suEXEC Support

If you want the LiveJournal code to run as a user other than what your webserver runs as, then you'll need suEXEC Official Apache suEXEC documentation support in Apache. You're free to figure that out yourself. We'll assume your webserver is running as user lj, though it doesn't have to run as any certain user to work.

In fact, the LiveJournal code never writes to disk, so as long as it can write to the database (which is essential, obviously), you can run the code as any user, including nobody or www-data, both of which are common in out-of-the-box configurations.

### Virtual Hosts

You can run the LiveJournal code inside or outside of a `<VirtualHost>` section in Apache's `httpd.conf` file. However, make note that you can't (yet) have two VirtualHosts running parallel copies of the code. In the future we'll fix that, but for now if you really need two installations on the same machine, you'll need to run two sets of Apache processes, listening on different ports.

## Example `httpd.conf`

    ServerType standalone
    ServerRoot "/etc/apache-perl"
    PidFile /var/run/apache-perl.pid
    ScoreBoardFile /var/run/apache-perl.scoreboard
    Timeout 30
    KeepAlive Off

    MinSpareServers 5
    MaxSpareServers 40
    StartServers 10
    MaxClients 20
    MaxRequestsPerChild 500

    LoadModule mime_module        /usr/lib/apache/1.3/mod_mime.so
    LoadModule autoindex_module   /usr/lib/apache/1.3/mod_autoindex.so
    LoadModule dir_module         /usr/lib/apache/1.3/mod_dir.so

    Port 80
    User lj
    Group lj

    SendBufferSize 131072

    ServerName   www.livejournal.com
    PerlSetEnv   LJHOME /home/lj
    PerlRequire  /home/lj/cgi-bin/modperl.pl

This will work by itself (assuming mod_perl statically linked), or you can just tack on parts to your existing config.

`/home/lj` is only an example directory. You'll want to use the same directory used in .

If you'd like, you can put those last three lines in a VirtualHost block.