Apache configuration vhost supports multiple sites
Each developer may develop multiple projects at the same time. Even if a project is developed, the configuration of multiple module sites may occur. Using vhost in apache is a good solution. It not only solves the problem of web directory switching, but also ensures that cookies take effect normally. The vhost configuration is very simple. Follow these three steps:
1. Enable the apache vhost Module
In the http. conf configuration file, locate this line and remove #
# LoadModule vhost_alias_module modules/mod_vhost_alias.so
Remove the # sign before the Include conf/extra/httpd-vhosts.conf line below, indicating that the configuration information of the vhost is read from the configuration file
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
2. configure a vhost
We configure a vhost in the configuration file. The default configuration file has example in it. Let's modify it with reference (# note is the key)
ServerAdmin webmaster@dummy-host.example.com DocumentRoot "c:/Apache2/docs/dummy-host.example.com" # web directory path ServerName dummy-host.example.com # host name ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common
3. Restart apache
FAQ:
1. How to Solve the 403 problem?
The 403 error occurs because the Directory has no access permission. Therefore, modify the Directory label in http. conf.
Options FollowSymLinks AllowOverride None Order deny,allow Allow from 127.0.0.1