虚拟主机的域名访问控制

Linux下LAMP和Discuz搭建好,在windows的hosts设置:

192.168.101.230 www.test.com www.daixuan.com www.daixuanlinux.com


那么输入任何一个都可以打开Discuz论坛,如果我想禁用IP:192.168.101.230访问,禁用www.daixuanlinux.com域名访问,只允许www.test.com和www.daixuan.com访问Discuz论坛,该怎么做?


[root@daixuan ~]# mkdir /tmp/123

[root@daixuan ~]# chmod 600 /tmp/123      dameno用户无法访问/tmp/123

[root@daixuan ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>

    DocumentRoot "/tmp/123"          /tmp/123的权限是daemon无法访问

    ServerName www.daixuanlinux.com

</VirtualHost>

<VirtualHost *:80>

#   ServerAdmin [email protected]

    DocumentRoot "/data/www"

    ServerName www.test.com

    ServerAlias www.daixuan.com

#   ErrorLog "logs/dummy-host.example.com-error_log"

#   CustomLog "logs/dummy-host.example.com-access_log" common

   <Directory /data/www/abc/>

   AllowOverride AuthConfig

   AuthName "Please input your name and password"

   AuthType Basic

   AuthUserFile /data/.htpasswd

   require valid-user

   </Directory>

</VirtualHost>

[root@daixuan ~]# apachectl -t

Syntax OK

[root@daixuan ~]# apachectl restart


192.168.101.230和www.diaxuanlinux.com不可以访问!403

wKioL1ZcER2gGAReAAAvuvS9xwk775.png

wKiom1ZcELqhcXN_AAAzaqxbFCE968.png

www.test.com和www.daixuan.com可以访问

wKioL1ZcEVOj85HmAACBItINlx8461.png

wKiom1ZcEO-zEe7jAACAHEUP_R0658.png


你可能感兴趣的:(虚拟主机的域名访问控制)