Click or scroll down Circle me on Google+ Fork me on GitHub Follow me on Twitter Ask me on Stack Overflow Gild me on Reddit Code Ninja, Entrepreneur, Idiot ChalkHQ — consulting, prototyping, mentoring HighF.in — resolve innefficiencies in your startup's workflow DearDrum.org — online open-mic / creative space The Dirac Equation (click to WikiPedia) A maxim Sun Tzu references in his magnum opus The Art of War

If you know the enemy and know yourself, you need not fear the result of a hundred battles.
If you know yourself but not the enemy, for every victory gained you will also suffer a defeat.
If you know neither the enemy nor yourself, you will succumb in every battle.
Fork me on GitHub

Tags

actionscript ad-hoc networks Adobe AIR anonymous Apple array Browsing convert Debugger Error Facebook file permissions Flash Flex fonts function future Google Google Plus grid hackers html javascript logs loop network p2p php privacy regexp Security Server social ssl technology terminal time Twitter upgrade Web 2.0 Web 3.0 Web 4.0 Web 5.0 wordpress

Featured Posts

  • Javascript: Undefined parameters
  • The Web, A Look Forward
  • Let Postfix send mail through your Gmail Account – Snow Leopard
  • Archives

  • April 2013
  • December 2011
  • July 2011
  • June 2011
  • March 2011
  • February 2011
  • January 2011
  • November 2010
  • October 2010
  • September 2010
  • July 2010
  • May 2010
  • Categories

  • Code
  • Design
  • Opinion
  • Security
  • Tools
  • Uncategorized
  • Latest Posts

    Apache Virtual Hosts and Multiple IP Addresses

    Here's a pain in the ass issue if you're exhausted, it's 4am, and you can't see straight. If you make a weird error with this either subdomains for anything but the first IP address won't work, or incorrect subdomains on secondary IPs will still resolve to the first specified IP's default VirtualHost definition. Or some other unexpected behaviour that will drive you insane while you question DNS, Browser, and OS caching mechanisms and resolvers which most likely have nothing to do with the issue.

    Things to remember.

    The ServerAlias line should only be one line. Each alias needs to be separated by a space.
    The first defined VirtualHost for a given IP is that IP's default.
    Make sure ports.conf and httpd.conf are included in Apache2.conf
    ports.conf should look like this:

    NameVirtualHost 55.11.515.151:80
    NameVirtualHost 88.22.828.279:80
    Listen 80
    

    and httpd.conf should look like this:

    #turn off indexing globally
    Options -Indexes
     
    
    DocumentRoot /serv/sites/domain.com/public
    ServerName domain.com
    ServerAlias www.domain.com
    
     
    
    DocumentRoot /serv/sites/sub.domain.com/public
    ServerName sub.domain.com
    
     
    
    DocumentRoot /serv/sites/domain2.com/public
    ServerName domain2.com
    ServerAlias www.domain2.com domain3.com *.domain3.com
    
     
    
    DocumentRoot /serv/sites/sub.domain2.com/public
    ServerName sub.domain2.com