linux apache下虚拟主机配置方法
假设IP是192.168.1.183,有两个域名指向该IP,分别是21.cc,22.cc,
修改/etc/httpd/conf/httpd.conf,在文件的最后加入:
ServerName 192.168.1.183
NameVirtualHost 192.168.1.183
<VirtualHost 192.168.1.183>
ServerName 21.cc
DocumentRoot /var/www/21.cc
<Directory "/var/www/21.cc">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.183>
ServerName 22.cc
DocumentRoot /var/www/22.cc
<Directory "/var/www/22.cc">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
然后在/var/www/21.cc和/var/www/22.cc 下创建不同的index.php,在浏览器里输入http://21.cc 和 http://22.cc 即可看到效果了 !
网友评论