#默认站点页面存放目录权限
Options Indexes FollowSymLinks #站点索引,支持连接
AllowOverride None #访问控制
Order allow,deny #先允许再拒绝
Allow from all #允许所有
# Deny from ip #拒绝某个ip的访问
----------------------------------------------
添加ServerName web1.amao.com
1、个人主页支持“http://ip/~用户名”访问个人主页
a、修改配置文件,支持这种访问
vi /etc/httpd/conf/httpd.conf
找到
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled #去掉某个用户的访问
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
#UserDir public_html #用户的默认页面的目录
修改为
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled root
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
b、添加用户,并建立个人主页的目录
adduser test #添加用户
cd /home/test
mkdir public_html #在用户目录里面建立个人主页使用的目录
chown test.test public_html #配置个人主页使用的目录的权限
chmod o+x /home/test #给用户主目录添加其他用户列出权限(不加就打不开)
cd /home/test/public_html
echo "test" > index.html
c、重启服务并测试
service httpd restart
浏览器输入http://ip/~test测试
--------------------------------------------------------------------
基于名称的虚拟主机(重点)
1、做DNS
vi /etc/named.conf
改3个any
vi /etc/named.rfc1912.zones
添加
zone "amao.com" {
type master;
file "amao.com.hosts";
};
-----------------
cd /var/named/
cp named.localhost amao.com.hosts
vi amao.com.hosts
添加
www IN A 你的web服务器的ip
---------
chown root.named amao.com.hosts
service named restart
---------------------------------------------
再添加个agou.com的域名
2、在apache的配置文件中添加虚拟主机(先把个人主页做出了再做这个)
vi /etc/httpd/conf/httpd.conf
在文件最后添加
NameVirtualHost 192.168.100.1 #名称虚拟主机开在那个ip上
NameVirtualHost 192.168.100.1