域名绑定

域名绑定指一台服务器在多网站部署的时候,将每个域名绑定到其对应的网站目录,从而达到每个网站都可以通过域名访问且相会不会干扰的效果。

下面是一个配置文件范例(LAMP环境):

<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias other.mydomain.com
DocumentRoot "/data/wwwroot/default/mysite2"
ErrorLog "/var/log/httpd/www.mydomain.com_error_apache.log"
CustomLog "/var/log/httpd/www.mydomain.com_apache.log" common
<Directory "/data/wwwroot/default/mysite1">
Options Indexes FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

通过修改配置文件中域名相关的值(ServerName,ServerAlias等)实现绑定域名