apache

Configuring two server simultaneously at apache local


I wanna configure two server simutaneoulsy at my apache. one is with name localhost n another is with name shadaab.

What I did was edited C:\xampp\apache\conf\httpd.conf and added these lines at last of files

    NameVirtualHost localhost

    <VirtualHost localhost>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost 
    </VirtualHost> 


    NameVirtualHost shadaab

    <VirtualHost shadaab> 
        DocumentRoot "F:/projects/all/" 
        ServerName shadaab
    </VirtualHost> 

Restarted apache server. When I browse in url localhost its working fine but when I did for 'shadaab' it doesn't work.

Later on how mysql will be connected with shadaab server pelase help. What other changes do I need to do.


Solution

  • Your config is WAY off. I suggest reading some documentation.

    Your config should look something like:

    NameVirtualHost 127.0.0.1:80
    
    <VirtualHost 127.0.0.1:80>
        DocumentRoot "C:/xampp/htdocs"
        ServerName localhost 
    </VirtualHost> 
    
    <VirtualHost 127.0.0.1:80> 
        DocumentRoot "F:/projects/all/" 
        ServerName shadaab
    </VirtualHost>
    

    Or replace 127.0.0.1 with * to make apache listen on all IP addresses, not just the loopback.