Hosting multiple web applications with virtual host on Apache server
1. Add the following at the end of Apache’s httpd.conf file, which is located in ApacheHomeDir/conf/
# Listen for virtual host requests on all IP addresses NameVirtualHost 127.0.0.3:80 <VirtualHost 127.0.0.3:80> DocumentRoot C:/Sites/site1 ServerName myfirstsite.com # Other directives here <Directory "C:/Sites/site1"> Options +MultiViews +FollowSymLinks +Indexes AllowOverride None <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory> </VirtualHost> <VirtualHost 127.0.0.3:80> DocumentRoot C:/Sites/site2 ServerName mysecondsite.com # Other directives here <Directory "C:/Sites/site2"> Options +MultiViews +FollowSymLinks AllowOverride None <IfVersion < 2.3 > Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.3> Require all granted </IfVersion> </Directory> </VirtualHost>
2. Add the following to the host file.
127.0.0.3 myfirstsite.com 127.0.0.3 mysecondsite.com
The hosts file on Windows:
C:\Windows\System32\drivers\etc\hosts
The hosts file on Mac OS or Linux:
/etc/hosts
3. Restart the apache server.
4. Test your sites by going to the below url on a browser.
myfirstsite.com
mysecondsite.com
5. Click here for hosting multiple web apps with different port numbers on Apache.
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts