2013/07/05

MapWarper on Ubuntu

Command list for installing mapwarper on Ubuntu 12.10. This hopefully provides better instruction.

$ sudo apt-get install python-software-properties software-properties-common
$ sudo apt-get install build-essential make
$ sudo apt-get install libxml2-dev libxslt1-dev
$ sudo apt-get install imagemagick git
$ sudo apt-add-repository ppa:ubuntugis/ppa
$ sudo apt-get update
$ sudo apt-get install gdal-bin
$ sudo apt-get install libgdal-ruby
$ sudo apt-get install libmapscript-ruby
$ sudo apt-get install postgresql-9.1-postgis
$ sudo apt-get install ruby1.8
$ sudo apt-get install ruby1.8-dev
$ sudo apt-get install libpq-dev
$ sudo apt-get install libcurl4-openssl-dev
$ sudo apt-get install apache2-threaded-dev

$ wget http://production.cf.rubygems.org/rubygems/rubygems-1.7.2.tgz
$ tar xvpzf rubygems-1.7.2.tgz
$ cd rubygems-1.7.2/
$ sudo ruby setup.rb
$ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

$ sudo gem install rails -v=2.3.5
$ gem list
# if rake version is not 0.9.2.2 (usually higher), then reinstall rake
$ sudo gem uninstall rake
You have requested to uninstall the gem:
        rake-10.0.4
rails-2.3.5 depends on [rake (>= 0.8.3)]
nokogiri-1.5.9 depends on [rake (>= 0.9)]
georuby-2.0.0 depends on [rake (>= 0)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]
Remove executables:
        rake
in addition to the gem? [Yn]
Removing rake
Successfully uninstalled rake-10.0.4

$ sudo gem install rake -v=0.9.2.2

$ sudo gem install yahoo-geoplanet -v=0.2.1
# previous successful with i18n-0.6.1, later successful with i18n-0.6.4

$ sudo gem install nokogiri -v=1.5.9
$ sudo gem install georuby -v=2.0.0

$ sudo gem install pg -v=0.15.1
Fetching: pg-0.15.1.gem (100%)
Building native extensions.  This could take a while...
Successfully installed pg-0.15.1
1 gem installed
Installing ri documentation for pg-0.15.1...

Invalid output formatter

For help on options, try 'rdoc --help'

ERROR:  While generating documentation for pg-0.15.1
... MESSAGE:   exit
... RDOC args: --ri --op /usr/lib/ruby/gems/1.8/doc/pg-0.15.1/ri
    -f fivefish -t pg: The Ruby Interface to PostgreSQL -m README.rdoc
    lib Contributors.rdoc History.rdoc Manifest.txt README-OS_X.rdoc
    README-Windows.rdoc README.ja.rdoc README.rdoc POSTGRES LICENSE
    ext/gvl_wrappers.c ext/pg.c ext/pg_connection.c ext/pg_result.c
    --title pg-0.15.1 Documentation --quiet

$ sudo gem install fastercsv -v=1.5.5
$ sudo gem install passenger -v=4.0.3
Fetching: daemon_controller-1.1.4.gem (100%)
Fetching: passenger-4.0.3.gem (100%)
Successfully installed daemon_controller-1.1.4
Successfully installed passenger-4.0.3
2 gems installed

$ sudo gem install oauth -v=0.4.7

$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo passenger-install-apache2-module
Welcome to the Phusion Passenger Apache 2 module installer, v4.0.3.

This installer will guide you through the entire installation process.
It shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you
on how to solve any problems.

The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

   LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/ \
              passenger-4.0.3/libout/apache2/mod_passenger.so
   PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.3
   PassengerDefaultRuby /usr/bin/ruby1.8

After you restart Apache, you are ready to deploy any number of
Ruby on Rails applications on Apache, without any further
Ruby on Rails-specific configuration!

Deploying a Ruby on Rails application: an example

Suppose you have a Rails application in /somewhere.
Add a virtual host to your Apache configuration file and
set its DocumentRoot to /somewhere/public:

   
      ServerName www.yourhost.com
      # !!! Be sure to point DocumentRoot to 'public'!
      DocumentRoot /somewhere/public
      
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
      
   

And that's it! You may also want to check the Users Guide for security
and optimization tips, troubleshooting and other useful information:

  /usr/lib/ruby/gems/1.8/gems/passenger-4.0.3/doc/Users guide Apache.html


$ sudo vi /etc/apache2/mods-available/passenger.load
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/ \
           passenger-4.0.3/libout/apache2/mod_passenger.so

$ sudo vi /etc/apache2/mods-available/passenger.conf
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.3
PassengerDefaultRuby /usr/bin/ruby1.8

$ sudo a2enmod passenger

$ sudo vi /etc/apache2/sites-available/warper.mysite.org

    ServerName warper.mysite.org
    RedirectMatch ^/$ http://warper.mysite.org/warper/
    ProxyRequests off
    ProxyPass /warper/ http://localhost:3000/
    
        ProxyPassReverse /
    


$ sudo a2ensite warper.mysite.org
$ sudo service apache2 restart

$ wget http://home.gdal.org/fwtools/FWTools-linux-2.0.6.tar.gz
$ tar xvpzf FWTools-linux-2.0.6.tar.gz
$ cd FWTools-2.0.6/
$ ./install.sh
# so we have $HOME/FWTools-2.0.6/bin_safe/ for GDAL_PATH
# that will be used in development.rb or production.rb

$ sudo su - postgres
postgres$ createuser gis (the username running mapwarper)
Shall the new role be a superuser? (y/n) y
postgres$ createdb template_gis
postgres$ createlang plpgsql template_gis
postgres$ psql -f
          /usr/share/postgresql/9.1/contrib/postgis-2.0/postgis.sql template_gis
postgres$ psql -f
          /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql
          template_gis
postgres$ createdb -T template_gis mysite_db
postgres$ exit

$ cd ~
$ git clone git://github.com/timwaters/mapwarper.git
$ cd mapwarper
$ mkdir public/mapimages
$ mkdir public/mapimages/src
$ mkdir public/mapimages/dst
$ mkdir public/mapimages/dst/png

$ vi config/environments/development.rb
# or production.rb copied from production.example
SITE_URL
SITE_EMAIL
GDAL_PATH

$ cp config/initializers/session_store.example config/initializers/session_store.rb
$ cp config/database.example config/database.yml
$ vi config/database.yml
development:
  adapter: postgresql
  database: mysite_db
  username: marr
  password: topsecret

$ rake db:migrate
# when user is created, no db, rake db:create can be used;
# however, we need postgis-based db

$ cd; screen
$ cd mapwarper/script
$ ./server
# Ctrl A + D to detach screen

No comments: