Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting multiple local sites with XAMPP

I'm new to using XAMPP so this may be simple to some people.

I have a few php projects that I would like to be able to debug locally and view in the browser (not concurrently, but without having to change config files/copy project folders each time I want to work on a different project).

On IIS, you could set up multiple sites to serve from your machine, and I'm looking for something similar in XAMPP. When using IIS, I added multiple records to the Windows hosts file so I could access the locally hosted sites by typing friendly web-style addresses (like http://myproject1.dev)

Thanks.

like image 973
Greg Avatar asked Sep 07 '10 15:09

Greg


People also ask

Can I host multiple websites on XAMPP?

By default XAMPP is setup to run at http://localhost and serve pages that are kept under C:/xampp/htdocs. In this situation, if you want to develop multiple websites, you will need to create a folder under C:/xampp/htdocs for each website and keep the website files thereunder.


1 Answers

Greg, you're almost there--you need (like Moses said) to setup virtual hosts.

So if your Windows hosts file has

127.0.0.1    localhost 127.0.0.1    mysite-dev.com 127.0.0.1    anothersite-dev.com 

Your virtual hosts file (httpd-vhosts.conf) might look like:

<VirtualHost *:80>   DocumentRoot C:/xampp/htdocs/   ServerName localhost </VirtualHost>  <VirtualHost *:80>      ServerName mysite-dev.com      DocumentRoot "C:/sites/mysite-dev"      <Directory "C:/sites/mysite-dev">         Options Indexes FollowSymLinks         AllowOverride All         Order allow,deny         Allow from all     </Directory>  </VirtualHost>  <VirtualHost *:80>      ServerName anothersite-dev.com      DocumentRoot "C:/sites/anothersite-dev"      <Directory "C:/sites/anothersite-dev">         Options Indexes FollowSymLinks         AllowOverride All         Order allow,deny         Allow from all     </Directory>  </VirtualHost> 

Don't forget to restart the web server after you make any changes.

like image 53
jbnunn Avatar answered Oct 14 '22 16:10

jbnunn