The best way to install rails and rubygems is to NOT use the Ubuntu packages. This is because we need specific versions of certain things, including rails itself. Instead of using apt-get, we install rubygems from source and install rails alongside the other gems. Additionally, we can install passenger which lets us use Apache instead of WEBrick. Here are some installation notes.
For Ubuntu 10.10 (Maverick) or later use the following list:
sudo apt-get update sudo apt-get install ruby libruby ruby-dev rdoc ri libmagickwand-dev libxml2-dev libxslt1-dev apache2 apache2-threaded-dev build-essential git-core postgresql postgresql-contrib libpq-dev libsasl2-dev openjdk-6-jre postgresql-server-dev-9.1
note: need to evaluate if we still need openjdk-6-jre, as opposed to openjdk-7-jre
Get the latest Osmosis rather than installing it from the Ubuntu repositories.
cd /wherever/you/download/stuff/ wget http://bretth.dev.openstreetmap.org/osmosis-build/osmosis-latest.tgz tar xvfz osmosis-latest.tgz cd osmosis-* chmod a+x bin/osmosis cd ~
Note: be sure to read the README.txt file in the bin/osmosis directory. It may recommend something like the following:
sudo ln -s /wherever/you/download/stuff/osmosis-*/bin/osmosis /usr/bin/osmosis
Note: Installing the Gems from http://rubygems.org/pages/download helped work around some issues encountered with the version outlined below when installing on Ubuntu 12.10 on a VPS.
wget http://files.rubyforge.vm.bytemark.co.uk/rubygems/rubygems-1.3.7.tgz tar -xzvf rubygems-1.3.7.tgz cd rubygems-1.3.7/ sudo ruby setup.rb sudo ln -s /usr/bin/gem1.8 /usr/bin/gem cd ~
Back to main page
Now go back to the the next step on the Rails Port page, and finish the installation.
When the Rails Port is working to your satisfaction, you can try installing Passenger, below, which will move your installation from the WEBrick http gem to Apache as a webserver.
When you've got the site working, you might want to use Passenger, as it will help with deployment of the Rails Port to Apache, instead of the Ruby-based WEBrick web server.
Installing the Passenger Gem and Mod
It is highly recommended that you confirm the latest Passenger installation instructions at: https://www.phusionpassenger.com/download/#open_source
As of 12/19/12, the instructions were as follows:
sudo gem install passenger sudo passenger-install-apache2-module
Create a new file /etc/apache2/conf.d/passenger with the following contents (change to correct version of passenger):
Note: The installation process may provide this information for you. Please use the text from the installation process, which should look somewhat similar to the text below.
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3 PassengerRuby /usr/bin/ruby1.8
If you just want to use the default VirtualHost (/etc/apache2/sites-enabled/default) for your rails_port app, change the docroot to point to the public/ folder, e.g.
vi /etc/apache2/sites-enabled/default ...default file contents... DocumentRoot /home/user/openstreetmap-website/public RailsEnv development ...
Be sure to remove any other references to DocumentRoot for that particular VirtualHost entry.
This next step may not be necessary, but you may also want to add the following information to that VirtualHost entry
<Directory /home/user/openstreetmap-website/public> Allow from all Options -MultiViews </Directory>
Configuring the Rails Port
Because apache runs as www-data (or whatever you've changed it to, you will need to change the owner of the app path:
chown -R www-data:www-data /home/user/openstreetmap-website/
And... if you are running in production, you may want to be sure to precompile your assets:
cd /home/user/openstreetmap-website/ sudo bundle exec rake assets:precompile
Start it all back up!
sudo service apache2 restart
And, go to your VirtualHost URL and see what's going on!
Notes on Using Passenger Standalone: Don't do it!
DO NOT USE PASSENGER STANDALONE. If you do, Potlatch2 will not work, because Passenger Standalone is based on nginx, which removes HTTP headers with underscores unless you explicitly configure it not to do so. This causes the X_HTTP_METHOD_OVERRIDE header to be ignored, which in turn causes the "create changeset" API request to be considered a POST request, while the API expects a PUT request. This, in turn, gives you a beautiful 404 error (resulting in a nondescript "could not create changeset" error in Potlatch 2) and a great opportunity to spend many hours debugging this "feature". Also, passenger standalone doesn't seem to have a user-editable config where you could change this behavior. For further reference, see: