Sharing a single Redmine code across multiple virtual hosts

Here is a quick walkthrough on setting up a single RedMine code to serve multiple vhosts/clients with their own database.

By default all uploaded files would be stored in the same `files’ subdir, so to have proper file upload isolation across the vhosts/clients you will need to install the « redmine_attachment_storage.zip » plugins that allows you to set the file storage dir per client : http://www.redmine.org/boards/2/topics/140

So, here we go.

  • Everything will be hosted under `/var/www/redmine-vhosts’ :
    # mkdir -p /var/www/redmine-vhosts
    # mkdir -p /var/www/redmine-vhosts/env/files
    # mkdir -p /var/www/redmine-vhosts/env/root
    # chown -R www-data: /var/www/redmine-vhosts
  • Unpack redmine in to `/var/www/redmine-vhosts/common-redmine’.

Now, to setup a new site :

  • Symlink `common-redmine’ to `envs/root/${SITE}’ and create a dedicated `envs/files/${SITE}’ for storing uploaded files :
    # mkdir /var/www/redmine-vhosts/envs/files/${SITE}
    # chown nobody: /var/www/redmine-vhosts/env
    # ln -s ../../common-redmine /var/www/redmine-vhosts/envs/root/${SITE}
  • Database definition for this new site :
    # cat <<EOF >> /var/www/redmine-vhosts/common-redmine/config/database.yml
    
    "${SITE}":
      adapter: postgresql
      host: 127.0.0.1
      username: redmine
      password: redmine
      database "redmine.${SITE}"
    EOF
  • Email configuration for the site :
    # cat <<EOF >> /var/www/redmine-vhosts/common-redmine/config/email.yml
    
    "${SITE}":
      delivery_method: :smtp
      smtp_settings:
      address: 127.0.0.1
      port: 25
      domain: example.net
    EOF
  • Configure the environments rb for the site :
    # cat <<EOF > /var/www/redmine-vhosts/common-redmine/environments/${SITE}.rb
    config.cache_classes = true
    config.action_controller.consider_all_requests_local = false
    config.action_controller.perform_caching             = true
    config.action_mailer.raise_delivery_errors = false
    config.action_mailer.logger = nil
    
    REDMINE_ATTACHMENT_STORAGE_CONFIG = {
    :path => "/var/www/redmine-vhosts/envs/files/${SITE}/",
    }
    EOF

Finally, create a Apache vhost conf for your site :

# cat <<EOF > /etc/apache2/sites-available/${SITE}

ServerName ${SITE}

RailsEnv ${SITE}
RailsBaseURI /

DocumentRoot /var/www/redmine-vhosts/envs/root/${SITE}/public
Order allow,deny
Allow from all

CustomLog /var/log/apache2/access.${SITE}.log combined
ErrorLog /var/log/apache2/error.${SITE}.log
EOF
# a2ensite ${SITE}
# /etc/init.d/apache2 force-reload
Ce contenu a été publié dans code. Vous pouvez le mettre en favoris avec ce permalien.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *

*