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: , , , , , , , , , ,

23 Responses to “Warehouse installation tutorial”

  1. 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

  2. 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.

  3. 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

  4. changelog says:

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

  5. 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

  6. 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.

  7. 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

  8. 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.

  9. 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!

  10. 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.

  11. Trey says:

    Thanks! That did the trick. Much appreciated.

  12. changelog says:

    Glad it worked out for you.

  13. 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.

  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.

  15. 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.

  16. 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! :)

  17. 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.

  18. 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 !

  19. Adriana says:

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

  20. 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!

  21. 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.

  22. changelog says:

    Go to Warehouse’s FAQ to see the list of commands available. They have several commands to import users into warehouse and get them into the SVN daemon.

Leave a Reply