1. Create the virtual host entries
Go to folder "C:\xampp\apache\conf". Then search the follow line "Include conf/extra/httpd-vhosts.conf" and if it has # symbol in front of it. Remove the #symbol.
X:\<path to your xampp installation>\apache\conf\extra\httpd-vhosts.conf
X:\<path to your xampp installation>\apache\conf\extra\httpd-vhosts.conf
NameVirtualHost *:80
Then you can start adding your virtual hosts. The following listing is a skeleton of what I usually use. I will assume we create a project which should be accessible by entering http://testproject in your browser’s address bar.
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot D:/srv/xampp/projects/testproject/public ServerName testproject <Directory "D:/srv/xampp/projects/testproject/public"> Options Indexes FollowSymLinks Includes ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> </VirtualHost>
Just make sure the DocumentRoot exists and matches the Directory and remember the value you set for ServerName.
2. Edit your windows hosts file
Now that your apache is ready to go, you have to tell your system what to do if you enterhttp://testproject in your browser. The most simple way without having to deal with DNS or anything else is to edit your hosts file you can find here (should be obvious that you have to alter the path if you got windows installed elsewhere):
C:\WINDOWS\system32\drivers\etc
The file is just a simple text file which contains IP-to-hostname mappings. Edit the file with a text editor and append a new line which maps the hostname you specified in apache’s ServerName-directive to 127.0.0.1. You can place it just under the existing one which defines localhost. In the end, your file could look like this:
# some comment stuff 127.0.0.1 localhost 127.0.0.1 testproject
No comments:
Post a Comment