I am currently using Windows 7 and I have XAMPP installed in the default folder so things might be different on your machine just Google them for your OS. Now lets get underway.
By default XAMPP sets up all the sites you create to have http://localhost as its top-level domain, and giving your site http://localhost/site as the url unless you install your site in the top-level folder. But what happens when you have multiple sites or you want to test out environments which would require you to have different domains, well I am going to teach you to do just that.
The Steps
- You need to have XAMPP installed ( )
- Open up the Xampp control panel and stop Apache (Ensure that you don’t have it running as a service … this is where doing so complicates things)
- Navigate to C:/xampp/apache/conf/extra or wherever you installed xampp
- Fire up your text editor with administrative privileges and open up httpd-vhosts.conf found in the C:/xampp/apache/conf/extra folder
- At the very bottom of the file paste the following
- NameVirtualHost *:80
- <VirtualHost *:80>
- DocumentRoot "C:/xampp/htdocs"
- ServerName localhost
- </VirtualHost>
- Now copy and paste the code below .. below the first code
- <VirtualHost *:80>
- DocumentRoot "C:/xampp/htdocs/testsite"
- ServerName testsite.dev
- ServerAlias www.testsite.dev
- <Directory "c:/xampp/htdocs/testsite">
- Order allow,deny
- Allow from all
- </Directory>
- </VirtualHost>
- <VirtualHost *:80>
- DocumentRoot "C:/xampp/htdocs/testsite"
- ServerName testsite.dev
- ServerAlias www.testsite.dev
- <Directory "c:/xampp/htdocs/testsite">
- AllowOverride All
- Require all Granted
- </Directory>
- </VirtualHost>
- Now we head over to our Windows Hosts File, to edit the HOSTS. the file will be located at C:/Windows/System32/drivers/etc/hosts, where hosts is the file.
- 127.0.0.1 localhost
- 127.0.0.1 localhost
- 127.0.0.1 www.somesite.dev
- 127.0.0.1 www.multisite.dev
- 127.0.0.1 demo.multisite.dev
- 127.0.0.1 www.testsite.dev #change this to the domain name you chose earlier
- Restart Apache and test to make sure it is working
0 comments:
Post a Comment