4. Configuring %LJ::DBINFO

%LJ::DBINFO is a hash that contains the necessary information for LiveJournal to connect to your database. For installations that require more than one database server, the directives to define each cluster database are also defined here.

Connection keys.  %LJ::DBINFO requires a master key that is labelled 'master', and also requires the correct address for connection to the database itself. If you are using a TCP based connection, you can specify a host key with the value of the location of the server (either the name, such as localhost, or the IP address, such as 127.0.0.1), and a port key for the database port (typically 3306). If instead you are using a socket based connection, you can specify a sock key with the value set to the socket file. Specify a user key for your database username, and a password key for your database password. [3]

If you used a different database name than the suggested “livejournal”, specify a dbname key with the value of the database name.

Roles.  The role key in %LJ::DBINFO is a hash that sets different “role” keys to the current configuration with boolean values. Roles are basically tasks assigned to the configuration. For example, to set up a server that will host your directory (which can get pretty intensive with a fair amount of users), you would do the following:

'role' => {
    'directory' => 1,
},

Example 8.1. Sample %LJ::DBINFO hash

%DBINFO = (
    # master must be named 'master'
        'master' => {
            'host' => 'localhost',
            'port' => 3306,

            # or, leave out host/port and use a socket to connect:
            # 'sock' => “/var/run/mysqld.sock”;

            # optional dbname, if not 'livejournal':
            # 'dbname' => 'livejournal', 

            'user' => 'lj',
            'pass' => 'ljpass',
            'role' => {
                'cluster1' => 1,

                # optionally, have Apache write its access logs to a MySQL database
                # 'logs' => 1,
            },
        },
);

That's the basic configuration for an installation with only one database server. Details about using more than one database server are covered later, in Section 2, “Setting up multiple database servers”.



[3] You should replace 'ljpass' with your actual password. Similarly, amend other fields as appropriate. Security permissions for the configuration files is handled through your operating system.