Managing additional Apache vhosts

jnewland edited this page Aug 19, 2010 · 2 revisions

If you host other sites on your server that are not managed by moonshine- perhaps they aren’t even Rails sites- you can still manage the vhost for these sites through your Moonshine manifest. For this example, let’s suppose that your Moonshine-managed application is configured for * The following would create a site that answered on When you see us using the “00_” prefix below, it’s to ensure that this vhost is checked for a ServerName match before the wildcard vhost. After you add this recipe to your manifest and deploy, you can upload content to the /srv/ directory it creates for you.

def blog_vhost
    file '/srv/',
      :ensure => :directory,
      :owner => configuration[:user]

    static_vhost = <<-VHOST
<VirtualHost *:80>

  DocumentRoot /srv/
  <Directory /srv/>
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

  RailsAutoDetect off

  # Deflate
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4.0[678] no-gzip
  BrowserMatch MSIE !no-gzip !gzip-only-text/html

  file "/etc/apache2/sites-available/",
    :alias => '',
    :ensure => :present,
    :content => static_vhost,
    :notify => service("apache2"),
    :require => file('/srv/')

  a2ensite ""
recipe :blog_vhost