Warehouse installation tutorial

Today I got to the office, and the first thing that popped into my eyes when I opened Twitterrific was this:

Rick Olson announces that Warehouse goes open-source

Rick Olson announcing that Warehouse is now open-source. Damn, it HAS to be Christmas! I have always loved the products that Active Reload builds, mostly because they follow the “do more with less” and “keep it simple stupid” principles, but also because their web-applications look awesome, thanks to Justin Palmer, the self-taught and self-proclaimed Design Ninja (I’ll have to agree with him on this one).

I have always wanted to give Warehouse a spin on my projects (professional and personal), but never got around to buy it because I was afraid it could be of no use for me (you guys have to find a way to distribute trials or something). Now that it’s open-source, I am going to try and provide a guide on how to install it.

Step 1. Requirements

Since I don’t have a spare computer lying around, I’m going to create a virtual machine to accomplish the task. I’ll try to build a dedicated SVN server, using Ubuntu Server (you can use anything else that’s Debian based) so all the dependencies will be installed using apt-get ;) Please take note that this is not a solution to be used in a production environment. It is most suited for “evaluation” purposes.

As for what virtualization software is concerned, there are several options:

So, go ahead and pick one, create a new virtual machine and install Ubuntu Server on that (any of these virtualization solutions can mount an ISO image, which you will have to download from Ubuntu’s website). I chose svnserver for the server hostname, and developer for the default username.

Step 2. Creating the user

Next we need to create a user for our Warehouse installation. The following commands create the warehouse user and add it to the www-data group (the same group Apache runs with by default).

  1. sudo adduser warehouse
  2. sudo adduser warehouse www-data

Step 3. Getting all the dependencies in place

After creating the user, you’ll have to add a repository so that you can apt-get the Phusion Passenger Apache module. Edit /etc/apt/sources.list and add the following lines in the end:

  1. # Phusion Passenger for Apache
  2. deb http://apt.brightbox.net hardy main

Afterwards, run the following command in order to update your apt repositories and install all the requirements to run Warehouse:

  1. sudo apt-get update
  2. sudo apt-get install git-core subversion subversion-tools ruby libsvn-ruby libmysql-ruby libopenssl-ruby ruby1.8-dev rdoc ri mysql-server mysql-client apache2 libapache2-mod-passenger

NB: The Passenger module package might have a bug where the mod_passenger.so is extracted to the root. If that happens, issue the following command:

  1. sudo mv /mod_passenger.so /usr/lib/apache2/modules/

Install Rails 2.0.2, Rake and Erubis

  1. sudo gem install rails -v=2.0.2
  2. sudo gem install rake
  3. sudo gem install erubis

Create a mysql user and databases for Warehouse:

  1. mysqladmin create warehouse -h localhost -u root -p
  2. mysqladmin create warehouse_development -h localhost -u root -p
  3. mysqladmin create warehouse_test -h localhost -u root -p

To add a new user and give it permission to those databases, run these commands inside a mysql shell:

  1. GRANT ALL PRIVILEGES ON warehouse.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;
  2. GRANT ALL PRIVILEGES ON warehouse_development.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;
  3. GRANT ALL PRIVILEGES ON warehouse_test.* TO 'warehouse'@'localhost' IDENTIFIED BY 'warehouse_user_password' WITH GRANT OPTION;

Step 4. Creating first SVN repository and gitting Warehouse

Login as warehouse. First off, we’ll create our first repository that will hold your project. Here’s how to do it:

  1. mkdir svn
  2. svnadmin create svn/topsecretproject
  3. chown -R :www-data svn

We’ll assume topsecretproject is your project name. Next, inside your home directory, issue the following commands:

  1. git clone git://github.com/entp/warehouse.git www
  2. chown -R :www-data www
  3. chmod -R 775 www

This will checkout the Warehouse code into /home/warehouse/www/. You can also get a tarball, but using this method is easier if you want to stay on the edge (I hear Rick is adding git support into Warehouse). It will also make the directory readable by the www-data group.
Next, we need to configure the database and run the first migration:

  1. cd www
  2. cp config/database.sample.yml config/database.yml

Edit database.yml and put in the correct values. After that, head back to /home/warehouse/www/ and run:

  1. mkdir log
  2. rake tmp:create
  3. RAILS_ENV=production rake db:schema:load

Step 5. Creating the Apache virtualhost

Log in again as the developer user, and cd to /etc/apache2/sites-available/. In that directory, create a file named warehouse-site with the following content:

  1. <VirtualHost *:80>
  2.     DocumentRoot /home/warehouse/www/public
  3.     ErrorLog /var/log/apache2/warehouse_error.log
  4.     LogLevel warn
  5.     CustomLog /var/log/apache2/warehouse_access.log combined
  6.     RailsEnv production
  7. </VirtualHost>

Finally, issue the following commands to enable the site you just configured, remove the default one, activate the rewrite module and restart apache:

  1. sudo ln -s /etc/apache2/sites-available/warehouse-site /etc/apache2/sites-enabled/warehouse-site
  2. sudo rm /etc/apache2/sites-enabled/000-default
  3. sudo a2enmod rewrite
  4. sudo apache2ctl restart

Now all you have to do is to open a browser window and type http://<your_virtual_machine_ip>/install in the URL and you’ll be up and running. I recommend, however, that you define the site with a ServerName, so that the sub-domains work properly.

Step 6. Giving your svn server a domain name and accessing it

Edit /etc/apache2/sites-available/warehouse-site and, right after the <VirtualHost> tag, add the following line:

  1.     ServerName svnserver.dev

You can change svnserver.dev to whatever you like. Afterwards, add that host to your hosts file. Here’s how to do it in Windows, Linux or Mac OS X. If all goes well, enter the new URL (including /install in the end) in your browser, and you should be seeing something like this:

Warehouse installation screen

In doubt, fill the “Absolute path to repository” with the following value:
/home/warehouse/svn/topsecretproject/, where topsecretproject is the repository name you’ve created in step 4. Also, after completing the installation, you might get an URL like http://topsecretproject.svnserver.dev/. In that case, you’ll have to go back to your hosts file and add another entry with that hostname.

Wrapping up


There you have it. Warehouse up and running syncing your first (and empty) repository. To serve it through apache (ie. enable you to make commits outside of the virtual machine), check this tutorial out. I hope this helps you in any way. I would appreciate some feedback, so don’t hesitate to fill that little form bellow.

Thanks and see you next time.

Tags: , , , , , , , , , ,

50 Responses to “Warehouse installation tutorial”

  1. Chris Craig says:

    When I execute: RAILS_ENV=production rake db:schema:load I get this:

    (in /var/www/svn)
    rake aborted!
    no such file to load — rubygems

    Any idea?

  2. Ulf says:

    Hey, thanks for the tutorial. Using Mongrel everything seems fine, I get the installer screen. But when I’m trying to use Apache, I get the following error message:

    We’re sorry, but something went wrong.

    We’ve been notified about this issue and we’ll take a look at it shortly.

    Unfortunately I can’t find anything in the logs. The error log is empty, the access log looks fine.

    Any suggestions?

    OS: Ubuntu 9.04 Server

    • Ulf says:

      Meanwhile I found the reason: only the development database has contents, the production DB is completely empty. How comes? I did a

      rake db:migrate

      and a

      rake db:schema:load

      Thanks in advance :-)

      • Ulf says:

        I seem to be blind ;-) The only thing I forgot was to add

        RAILS_ENV=production

        to my rake commands. Now everything’s fine. Thanks again.

  3. lordaba says:

    I am stuck at:

    There appears to be a database problem.

    *
    Your config/database.yml may not be written correctly. Please check it and fix any errors.
    *
    Your database schema may be out of date or nonexistant. Please run rake db:migrate to ensure that the database schema is up-to-date.
    *
    The database server may not be running. Please check whether it’s running, and start it if it isn’t.

    Error message:
    Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysld.sock’ (2) (Mysql::Error)
    Exception class:
    Mysql::Error
    Application root:
    /home/warehouse/www

    and my datbaase.yml is set to the correct directory based on mysql status command.

  4. Jörn says:

    I have a problem with my virtual host file:

    sudo apache2ctl restart
    Syntax error on line 7 of /etc/apache2/sites-enabled/warehouse-site:
    Invalid command ‘RailsEnv’, perhaps mis-spelled or defined by a module not included in the server configuration

    what is wrong? i hope you can help me…

    • changelog says:

      Do you have the passenger apache module enabled?
      If so, try removing the offending line and setting the environment in the environment.rb file on the application’s config directory. That should get you running.

  5. Witti says:

    Can’t browse the repository.
    Everytime I wan’t to browse I get an Error 500.

    The log tells me the following error message:

    ActionView::TemplateError (undefined method `length’ for #) on line #88 of browser/dir.html.erb

    Any ideas?

  6. mds5000 says:

    Great tutorial… I was able to get the install page to display but its not serving any of the pictures and none of the links work. I’m guessing this is an apache configuration problem but have no idea where to look first. Any help is appreciated.

  7. James says:

    I’m not sure what was going on, but I seem to have fixed that. But now when I run:

    RAILS_ENV=production rake db:schema:load

    I get:

    Access denied for user ‘warehouse’@'localhost’ (using password: NO)

    why would it not be using the password? I reset the password in mysql to make sure it was set correctly.

  8. James says:

    Why does installing Phusion Passenger require removing a lot of the php5 modules, such as phpmyadmin?

  9. Luis Martins says:

    Thanks again, i suppose thats the case also for svn users, i mean, i have to create them manually also? I though that by creating them on the Warehouse panel the system would take care of creating those users in the config files for each repository.

  10. Adriana says:

    Join to Warehouse…
    Does this seems to be a bug? Trying to import the users from apache htpasswd file I’m getting from “warehouse:import_users” rake the error: “uninitialized constant Warehouse::Command::User”
    Command line used: “rake warehouse:import_users CONFIG=config/htpasswd.conf”
    Maybe someone else tried it?

    Cheers!

  11. Adriana says:

    Fixed. I had more non-alphanumeric character in my password that made Sequel to crash.

  12. Adriana says:

    Hi, back on this. I configured apache and it’s running on production. But I can’t use any command line available with warehouse cause I’m getting this annoying error.

    rake aborted!
    bad URI(is not URI?): mysql://root:password@localhost/xorn_production

    Seems to be a problem with mysql server?! All tables are fine in “xorn_production” database besides “changesets” table with empty records in.

    Thanks !

  13. Adriana says:

    Silly me! I have started the server and now I’m running Warehouse installation on my http://localhost:3000. Thanks a lot guys! :)

    • changelog says:

      @Adriana: Although that’s not the “production” server (it’s only to check if everything is OK), it should work fine. You should still check if apache is running and if the settings are OK. Let me know.

  14. Adriana says:

    Hi, for me it’s weird, I took Warehouse tar.gz archive from http://github.com/entp/warehouse/tree/master. All packages installation steps went fine but I didn’t finished the warehouse configuration because I don’t have /install directory. I don’t have any other config errors. I’m running it on debian and ubuntu OS.

    Thanks.

    • changelog says:

      @Luis: You have to create them yourself, then add them to Warehouse.

      @Adriana: Did you start the server? You could try starting it with script/server, mongrel or the like. Besides, there is no install directory, only a controller. E-mail me at < me AT andremedeiros DOT info > if you need further help.

  15. Luis Martins says:

    Hi, newbie here. I’ve managed to install Warehouse, after configuring Subversion. Im not sure if everything went ok because after working for a while, i now cannot connect to the repositories with versionsapp. The system always returns an error related to not being able to find any repository.

    Anyone had this kind of issues?

    When adding a new repository to Warehouse, is it supposed to be created in the file system automatically or do i have to create by hand?

    Thanks.

  16. Trey says:

    Thanks! That did the trick. Much appreciated.

  17. changelog says:

    @Trey What OS are you deploying Warehouse on? I’ve had cases where, in linux, it would assume /tmp/mysql.sock when it’s really lying on /var/run/mysqld/mysqld.sock. So, here are a couple of things you need to make sure of: 1) Have the mysql gem installed (native one, not the ruby based one). 2) If that doesn’t solve it, try adding this line to your database.yml configurations:

    socket: /var/run/mysqld/mysqld.sock

    Good luck.

  18. Trey says:

    Thanks for the guide! I’m a complete n00b and am trying to get warehouse going for a small group of developers. I keep running into an error following this: RAILS_ENV=production rake db:schema:load. The process stops and I get “Can’t connect to mysql server through socket /tmp/mysql.sock (2)” I’m a little lost but am guessing it’s some sort of permissions problem with mysql and the install. Any help would be greatly appreciated. Again, thanks a ton for writing this guide!

  19. changelog says:

    @Devan I’m not sure, although I doubt it. I recommend you to join #activereload on irc.freenode.net and ask technoweenie about that issue. Sounds like a great improvement.

  20. Devan says:

    This is an excellent, well written and thorough tutorial on installing warehouse – it is much appreciated. Wish I had found it hours and hours ago – would have saved me a whole day!

    I am wondering if you know whether Warehouse can access a repo on another svn server at another location, e.g. svn://overthere.com/thatrepo instead of having the repositories on the local machine? I have tried, and get errors when trying to browse the repo.

    Thanks again,
    Devan

  21. changelog says:

    @tav Thanks for the feedback. Well, 755 would depend on how you’d setup the users and all. I chose an approach where the “warehouse” user would run under the same group as apache, but not as the user per-se, so I’m not sure 755 would be enough. Anyway, I’ll give it a try and let you know.

  22. tav says:

    Thanks!!

    Near perfect installation guide! Just needs some modifications with regards the permissions. I think chmod -R 755 is what’s needed?

    Thanks again, tav

  23. changelog says:

    @Kevin Did you catch the file and line that caused the error?

  24. Kevin says:

    Thanks for the quick reply!

    You were right – I chmodded the directory again and it worked.

    I got to the next screen but when I click sync it says: “A 500 error occurred, please check your logs” and in the log it says “FloatDomainError (NaN)…”

    Know what would have caused this?

    Thanks,
    Kevin

  25. changelog says:

    @Kevin Thanks! I’d suspect that it’s trying to write the config file and not being able to. Try chmodding the directory again, and let me know how it goes. Good luck.

  26. Kevin says:

    Cool tutorial!

    I get to the point where I bring up the install page but when I enter all the info and click install it says: Permission denied – /home/warehouse/www/config/initializers/warehouse.rb

    any clue as to what the issue is?

    Thanks,
    Kevin

  27. changelog says:

    In that case, I’d take that to the Warehouse community forum. You might find a solution there. Good luck and I’m sorry I couldn’t be of any more help.

  28. Witti says:

    Where can I find the community forum? I only found a forum about lighthouse but not about warehouse.

  29. Jörn says:

    Thanks for your reply.
    i can’t install it cause ibapr1 is not available:

    root@www:~# sudo apt-get install libapache2-mod-passenger
    Reading package lists… Done
    Building dependency tree… Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.

    Since you only requested a single operation it is extremely likely that
    the package is simply not installable and a bug report against
    that package should be filed.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies:
    libapache2-mod-passenger: Depends: libapr1 but it is not installable
    Depends: libaprutil1 but it is not installable
    Depends: libc6 (>= 2.4) but 2.3.6-0ubuntu20.5 is to be installed
    Depends: libgcc1 (>= 1:4.1.1-21) but 1:4.0.3-1ubuntu5 is to be installed
    Depends: libruby1.8 (>= 1.8.6.111) but 1.8.4-1ubuntu1.6 is to be installed
    Depends: libstdc++6 (>= 4.1.1-21) but 4.0.3-1ubuntu5 is to be installed
    E: Broken packages
    root@www:~# sudo apt-get install libapr1
    Reading package lists… Done
    Building dependency tree… Done
    Package libapr1 is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    E: Package libapr1 has no installation candidate

    can you tell me, were i get it from?
    thanks

  30. changelog says:

    What distribution and version of Linux are you using? You could try building passenger from source like so:

    sudo gem install passenger

    Install the development tools (ruby-dev, build-essentials, etc) first.

  31. Jörn says:

    I got it! thanks!

  32. changelog says:

    That’s awesome!

Leave a Reply