{"id":44,"date":"2011-02-02T11:16:58","date_gmt":"2011-02-02T10:16:58","guid":{"rendered":"http:\/\/wp.locallost.net\/?p=44"},"modified":"2011-02-03T13:14:12","modified_gmt":"2011-02-03T12:14:12","slug":"sharing-a-single-redmine-across-virtual-hosts","status":"publish","type":"post","link":"https:\/\/locallost.net\/?p=44","title":{"rendered":"Sharing a single Redmine code across multiple virtual hosts"},"content":{"rendered":"<p>Here is a quick\u00a0walkthrough\u00a0on setting up a single RedMine code to serve multiple vhosts\/clients with their own database.<\/p>\n<p>By default all uploaded files would be stored in the same `files&rsquo; subdir, so to have proper file upload isolation across the vhosts\/clients you will need to install the \u00ab\u00a0redmine_attachment_storage.zip\u00a0\u00bb plugins that allows you to set the file storage dir per client : <a title=\"redmine_attachment_storage.zip\" href=\"http:\/\/www.redmine.org\/boards\/2\/topics\/140\">http:\/\/www.redmine.org\/boards\/2\/topics\/140<\/a><\/p>\n<p><!--more--><\/p>\n<p>So, here we go.<\/p>\n<ul>\n<li>Everything will be hosted under `\/var\/www\/redmine-vhosts&rsquo; :\n<pre># mkdir -p \/var\/www\/redmine-vhosts\r\n# mkdir -p \/var\/www\/redmine-vhosts\/env\/files\r\n# mkdir -p \/var\/www\/redmine-vhosts\/env\/root\r\n# chown -R www-data: \/var\/www\/redmine-vhosts<\/pre>\n<\/li>\n<li>Unpack redmine in to `\/var\/www\/redmine-vhosts\/common-redmine&rsquo;.<\/li>\n<\/ul>\n<p>Now, to setup a new site :<\/p>\n<ul>\n<li>Symlink `common-redmine&rsquo; to `envs\/root\/${SITE}&rsquo; and create a dedicated `envs\/files\/${SITE}&rsquo; for storing uploaded files :\n<pre># mkdir \/var\/www\/redmine-vhosts\/envs\/files\/${SITE}\r\n# chown nobody: \/var\/www\/redmine-vhosts\/env\r\n# ln -s ..\/..\/common-redmine \/var\/www\/redmine-vhosts\/envs\/root\/${SITE}<\/pre>\n<\/li>\n<li>Database definition for this new site :\n<pre># cat &lt;&lt;EOF &gt;&gt; \/var\/www\/redmine-vhosts\/common-redmine\/config\/database.yml\r\n\r\n\"${SITE}\":\r\n  adapter: postgresql\r\n  host: 127.0.0.1\r\n  username: redmine\r\n  password: redmine\r\n  database \"redmine.${SITE}\"\r\nEOF<\/pre>\n<\/li>\n<li>Email configuration for the site :\n<pre># cat &lt;&lt;EOF &gt;&gt; \/var\/www\/redmine-vhosts\/common-redmine\/config\/email.yml\r\n\r\n\"${SITE}\":\r\n  delivery_method: :smtp\r\n  smtp_settings:\r\n  address: 127.0.0.1\r\n  port: 25\r\n  domain: example.net\r\nEOF<\/pre>\n<\/li>\n<li>Configure the environments rb for the site :\n<pre># cat &lt;&lt;EOF &gt; \/var\/www\/redmine-vhosts\/common-redmine\/environments\/${SITE}.rb\r\nconfig.cache_classes = true\r\nconfig.action_controller.consider_all_requests_local = false\r\nconfig.action_controller.perform_caching             = true\r\nconfig.action_mailer.raise_delivery_errors = false\r\nconfig.action_mailer.logger = nil\r\n\r\nREDMINE_ATTACHMENT_STORAGE_CONFIG = {\r\n:path =&gt; \"\/var\/www\/redmine-vhosts\/envs\/files\/${SITE}\/\",\r\n}\r\nEOF<\/pre>\n<\/li>\n<\/ul>\n<p>Finally, create a Apache vhost conf for your site :<\/p>\n<pre># cat &lt;&lt;EOF &gt; \/etc\/apache2\/sites-available\/${SITE}\r\n\r\nServerName ${SITE}\r\n\r\nRailsEnv ${SITE}\r\nRailsBaseURI \/\r\n\r\nDocumentRoot \/var\/www\/redmine-vhosts\/envs\/root\/${SITE}\/public\r\nOrder allow,deny\r\nAllow from all\r\n\r\nCustomLog \/var\/log\/apache2\/access.${SITE}.log combined\r\nErrorLog \/var\/log\/apache2\/error.${SITE}.log\r\nEOF\r\n# a2ensite ${SITE}\r\n# \/etc\/init.d\/apache2 force-reload<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is a quick\u00a0walkthrough\u00a0on 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&rsquo; subdir, so to have proper file upload isolation across the &hellip; <a href=\"https:\/\/locallost.net\/?p=44\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[4],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-code"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2Bei9-I","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=44"}],"version-history":[{"count":59,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/44\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}