Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Chandler Tayek
Chandler Tayek
5,513 Points

I need help setting up virtual host for Xampp.

I need to set up virtual hosting for my new php file so I don't have to go reconfigure where my Apache points to. If anyone can help me understand why My first virtual host works but not my other ones it would greatly please me.

<VirtualHost *:80>
    ServerAdmin (myemailhere)
    DocumentRoot "C:/xampp/htdocs/test.php"
    ServerName treehouse.test
    ServerAlias www.treehouse
    ErrorLog "logs/dummy-host3.example.com-error.log"
    CustomLog "logs/dummy-host3.example.com-access.log" common
    <Directory "C:/xampp/htdocs/test.php">
        ##AllowOveride all
        Require all granted
    </Directory>
</VirtualHost>

1 Answer

Aj Villalobos
Aj Villalobos
1,864 Points
NameVirtualHost *
  <VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
  </VirtualHost>

  <VirtualHost *>
    DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
    ServerName clientA.local
  <Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

<VirtualHost *>
    DocumentRoot "C:\Documents and Settings\Me\My Documents\clientB\website"
    ServerName clientB.local
  <Directory "C:\Documents and Settings\Me\My Documents\clientB\website">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

As you can see, you need the NameVirtualHost *, maybe try to remove the :80, I don't know if that the same with unix/linux.

Chandler Tayek
Chandler Tayek
5,513 Points

Yea I already have the NameVituralHost thingy at the top. I already have a vitural host and it is running fine but when I copy and change some of the directory roots then it doesn't work. :/