Currently I am using XAMPP application to test my websites.
Why Virtual Host?
It will gives you freedom to use your domain-name instead sub directory of 'localhost' in URL.
Ex.
http://project-name/ instead of http://localhost/project-name
To setup Virtual Host (multisite) using xampp in windows,
Step 1:
Locate 'httpd-vhosts.conf' file in xampp-apache installation. Mostly in "C:\xampp\apache\conf\extra"
Edit above file (using notepad) by appending,
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
#Above code will make sure your access
#to default 'htdocs' directory for 'localhost'.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project-name"
ServerName project-name.local
ServerAlias project-name.local
ErrorLog "logs/project-name.local-error.log"
CustomLog "logs/project-name.local-access.log" common
<Directory "C:/xampp/htdocs/project-name">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#Change 'project-name' with your domain-name
Why Virtual Host?
It will gives you freedom to use your domain-name instead sub directory of 'localhost' in URL.
Ex.
http://project-name/ instead of http://localhost/project-name
To setup Virtual Host (multisite) using xampp in windows,
Step 1:
Locate 'httpd-vhosts.conf' file in xampp-apache installation. Mostly in "C:\xampp\apache\conf\extra"
Edit above file (using notepad) by appending,
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
#Above code will make sure your access
#to default 'htdocs' directory for 'localhost'.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/project-name"
ServerName project-name.local
ServerAlias project-name.local
ErrorLog "logs/project-name.local-error.log"
CustomLog "logs/project-name.local-access.log" common
<Directory "C:/xampp/htdocs/project-name">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
#Change 'project-name' with your domain-name
Step 2:
Locate 'host' file in "C:\Windows\System32\drivers\etc"
Append below lines,
127.0.0.1 localhost
127.0.0.1 project-name.local
Step 3:
Restart Apache Server.
Note:
>It's not mandatory to use '.local' extension. But do not use TLD's in local domain-name.
>Sometimes you may need to restart Windows to host take effect.
No comments :
Post a Comment