{"id":688,"date":"2014-06-27T05:57:39","date_gmt":"2014-06-27T05:57:39","guid":{"rendered":"http:\/\/ntsplhosting.com\/blog\/\/?p=688"},"modified":"2024-09-18T07:36:25","modified_gmt":"2024-09-18T07:36:25","slug":"setting-up-virtual-hosts-for-xampp","status":"publish","type":"post","link":"https:\/\/www.ntsplhosting.com\/blog\/setting-up-virtual-hosts-for-xampp\/","title":{"rendered":"Setting Up Virtual Hosts for XAMPP"},"content":{"rendered":"<p>Virtual Hosts give you the ability to &#8220;host&#8221; more than one Web site and domain on your computer. With a virtual host you can have separate local domain names for each of your Web sites: for example, <b>http:\/\/clientA\/<\/b> for one site and <b>http:\/\/clientB\/<\/b> for another.<\/p>\n<p><b>Adding a Virtual Host is a 2-step process:<\/b><\/p>\n<ul>\n<li><b style=\"line-height: 1.5;\">Launch Notepad and open the hosts file located at<\/b><\/li>\n<\/ul>\n<p><strong>C:\\windows\\system32\\drivers\\etc\\hosts.<\/strong> (You may not be able to see the windows folder\u2013some files are hidden by default under Windows)<\/p>\n<ul>\n<li><b>At the end of that file type:<\/b><br \/>\n<b>127.0.0.1\u00a0\u00a0\u00a0\u00a0\u00a0 clientA.in<\/b><\/li>\n<\/ul>\n<p>127.0.0.1 is how a computer refers to itself\u2014it\u2019s an IP address that points back to the computer, kind of like a computer\u2019s way of saying &#8220;ME.&#8221; The second part <b>(clientA.in)<\/b> is the &#8220;domain&#8221; of the virtual host. To visit this domain in a Web browser you\u2019d type<b> http:\/\/clientA.in<\/b>. You don\u2019t have to add the .in part to the hosts files\u2014you could just as easily add <b>127.0.0.1 clientA<\/b> and access the site in your Web browser with <b>http:\/\/clientA<\/b>\u2014but I find it helpful for differentiating between a real Web site out on the Internet like <b>clientA.com<\/b>, and the test sites I have running on my own computer.<\/p>\n<p><b>In Notepad open the Apache configuration file located<\/b><\/p>\n<ul>\n<li><b> at C:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf<\/b><\/li>\n<li><b>At the bottom of that file add:<\/b><\/li>\n<\/ul>\n<pre class=\"code-structure\">NameVirtualHost *\r\n&lt;VirtualHost *&gt;\r\n\tDocumentRoot \"C:\\xampp\\htdocs\"\r\n\tServerName localhost\r\n&lt;\/VirtualHost&gt;\r\n&lt;VirtualHost *&gt;\r\n\t<b><span style=\"color: #3366ff;\">DocumentRoot \"C:\\Documents and Settings\\Me\\My Documents\\clientA\\website\"<\/span>\r\n\t<span style=\"color: #3366ff;\"> ServerName clientA.in<\/span>\r\n\t<span style=\"color: #3366ff;\"> &lt;Directory \"C:\\Documents and Settings\\Me\\My Documents\\clientA\\website\"&gt;<\/span><\/b>\r\n\t\tOrder allow,deny\r\n\t\tAllow from all\r\n\t&lt;\/Directory&gt;\r\n&lt;\/VirtualHost&gt;\r\n<\/pre>\n<p>The first five lines of code turn on the Virtual Host feature on Apache, and set up the <b>C:\\xampp\\htdocs<\/b> folder as the default location for <b>http:\/\/localhost<\/b>. That\u2019s important since you need to be able to access the XAMPP web pages at <b>http:\/\/localhost\/<\/b> so that you can use PHPMyAdmin.<\/p>\n<p>You\u2019ll need to modify the stuff highlighted in blue color. The first item \u2014 DocumentRoot \u2014 indicates where the files for this site are located on your computer.<\/p>\n<p>The second part\u2013<strong>ServerName<\/strong> \u2014 is the name you provided in step 2 above: the virtual host name.<\/p>\n<p>For example, clientA.in.<\/p>\n<p>The third item \u2014 the &lt;Directory&gt; part \u2014 is the same path you provided for the <strong>DocumentRoot.<\/strong><\/p>\n<p>This is required to let your Web browser have clearance to access these files.<\/p>\n<ul>\n<li><b style=\"line-height: 19px;\"><\/b><b style=\"line-height: 19px;\">Save and close the Apache configuration file, and restart Apache from the XAMPP control panel.<\/b><\/li>\n<li><b style=\"line-height: 1.5;\">Start a Web browser and type a URL for the virtual host. For example: http:\/\/clientA.local\/.You should now see the home page for your site.<\/b><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Virtual Hosts give you the ability to &#8220;host&#8221; more than one Web site and domain on your computer. With a virtual host you can have separate local domain names for each of your Web sites: for example, http:\/\/clientA\/ for one site and http:\/\/clientB\/ for another. Adding a Virtual Host is a 2-step process: Launch Notepad [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1481,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[21,22,25],"tags":[123,164,358,392],"_links":{"self":[{"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/posts\/688"}],"collection":[{"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/comments?post=688"}],"version-history":[{"count":5,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/posts\/688\/revisions"}],"predecessor-version":[{"id":37896,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/posts\/688\/revisions\/37896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/media\/1481"}],"wp:attachment":[{"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/media?parent=688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/categories?post=688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ntsplhosting.com\/blog\/wp-json\/wp\/v2\/tags?post=688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}