Installing Danbooru

I noticed a couple of searches for ‘running danbooru’ in my search phrases for this site, so I decided to post a little bit more about that.  I assume someone searching for this was actually searching for help with installing danbooru.  Admittedly, I had some difficulty with it.  For one thing, I’d never used psql in my life. 😛

Here’s the INSTALL file that’s packaged with the source code so you know what you’re getting yourself into before you even fetch the source tree from Subversion.

I should point out that installing Danbooru is not for the faint of heart.  You’ll need to know a bit about your linux distro and be comfortable (and have the requisite access) to install software packages as the root user.  An easier to install PHP-based clone, Shimmie, might be more suitable for your project if you are not.

First thing, and I’ll copy this directly from the INSTALL file, you’ll need the following packages installed on your system ( or more up to date versions thereof): gcc, g++, make, readline, zlib, flex, bison, gd2, bzip2, postgresql-8.3, postgresql-contrib-8.3, ruby, rubygems, memcached, subversion, apache, and phusion passenger

Once you have all that, you’ll also need the following ruby gems: postgres, diff-lcs, html5, memcache-client, aws-s3, json, rails (version 2.2.2)

Now that you’ve hopefully collected everything together it’s time to get to work.

From the INSTALL “It’s recommended you create a dedicated [Postgres database] account for running the Danbooru database and/or web processes. ”  I say do it.  It’s much easier than any other way I could think of setting this up.

  1. Use the createuser command while logged in as postgres to grant database access to the danbooru account.
  2. You will need to update the pg_hba.conf file to grant your danbooru account trusted localhost access. Make sure to restart the database server (/etc/init.d/postgresql-8.3 restart) after making any changes.

I should note that I had to make a couple of minor tweaks to get rails to actually connect to Postgres, but at the moment, I can’t remember what they were so hopefully you don’t run into the same problem I did.

The  rest is a fairly straightforward process, this is all taken verbatim from the most recent INSTALL file:

  1. To export from Subversion: “svn export svn://donmai.us/danbooru/trunk danbooru”
  2. Recursively change the owner of this directory to the danbooru account: “chown -R danbooru:danbooru danbooru”
  3. Create a public/data/sample directory.
  4. Compile the resizer at lib/danbooru_image_resizer: “ruby extconf.rb && make”. Do not make install it. If this fails you will need to figure out your gd2/libjpeg/libpng dependencies.
  5. Create new database.yml and local_config.rb files in the config directory. Example files are provided.
  6. Create the database: “createdb danbooru”
  7. Load the schema: “psql danbooru < db/postgres.sql”
  8. Run the migrations: “RAILS_ENV=production rake db:migrate”
  9. Start the job daemon: “RAILS_ENV=production app/daemons/job_task_processor_ctl.rb start”
  10. You now need a way of managing the Rails process. The preferred method is using the Phusion Passenger module (see section below). Alternatively you can use Mongrel or fastcgi, there are several examples on the web.
  11. [Not mentioned in INSTALL] You might want to remove the advertisement stuff from the templates or replace it with your own.  It crashed my installation when I tried to view pages when not logged in as the administrator.

I used FastCGI myself actually, so I know nothing about Phusion.

I might run through the installation process again and create a VDI image in the future that can simply be connected to VirtualBox and booted so people can play around with it with minimal hassle.  (That minimal hassle being setting the IP address.  I don’t know enough about Linux boot scripts to have it ask you by default to provide one.)

Sorry, that’s all the help I can deliver today, unfortunately, it’s been a while since I had done this.  Also, I’m a bit tired.

2 Responses to “Installing Danbooru”

  1. Vodkaholic

    Thanks for the help! But sadly this is way over my head dam shame