How to set up virtual hosts on Apache 2.2

前端 未结 2 653
礼貌的吻别
礼貌的吻别 2021-01-03 09:03

Can anyone direct me to a good tutorial on how to set up virtual hosts using Apache 2.2? Here\'s my situation:

I have Apache running on my laptop and I want two web

相关标签:
2条回答
  • 2021-01-03 09:37

    Just have 2 virtual hosts defined like this, but with differeing DocumentRoots:

    <VirtualHost *:80>
        ServerAdmin webmaster@dummy-host.somecompany.com
        DocumentRoot "/docs/dummy-host.somecompany.com"
        ServerName dummy-host.somecompany.com
        ServerAlias www.dummy-host.somecompany.com
        ErrorLog "logs/dummy-host.somecompany.com-error.log"
        CustomLog "logs/dummy-host.somecompany.com-access.log" common
    </VirtualHost>
    
    <VirtualHost *:8089>
        ServerAdmin webmaster@dummy-host.somecompany.com
        DocumentRoot "/docs/dummy-host.somecompany.com"
        ServerName dummy-host.somecompany.com
        ServerAlias www.dummy-host.somecompany.com
        ErrorLog "logs/dummy-host.somecompany.com-error.log"
        CustomLog "logs/dummy-host.somecompany.com-access.log" common
    </VirtualHost>
    
    0 讨论(0)
  • 2021-01-03 09:42

    First you need to instruct Apache to listen on the ports you need:

    Listen 80
    Listen 8089
    

    Second you need to tell it what to do with 80 and 8089 traffic:

    <VirtualHost *:80>
        DocumentRoot /website/site80
        ServerName internet.dev
    </VirtualHost>
    
    <VirtualHost *:8089>
        DocumentRoot /website/site8089
    </VirtualHost>
    

    Third you need to "allow" Apache to use those directories:

    <Directory "C:/website/site80">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    
    <Directory "C:/website/site8089">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    
    0 讨论(0)
提交回复
热议问题