vim /etc/sysconfig/network-scripts/ifcfg-eth0
修改如下内容
xxxxxxxxxx
BOOTPROTO=static
IPADDR=192.168.xxx.1
NETMASK=255.255.255.0
重启网络 service network restart
xxxxxxxxxx
setenforce 0
xxxxxxxxxx
service iptables stop
或者使用setup
命令,选择Firewall configuration
下的Security Level
并设置为Disabled
,然后保存退出
xxxxxxxxxx
rpm -ivh httpd-2.2.15-39.el6.i686.rpm
xxxxxxxxxx
vim /etc/httpd/conf/httpd.conf
xxxxxxxxxx
user add long
passwd long
chmod 705 /home/long
mkdir /home/long/public_html
cd /home/long/public_html
echo "This is Long's web" >> index.html
配置文件中
xxxxxxxxxx
<IfModule mod_userdir.c>
UserDir disabled
#UserDir public_html
</IfModule>
修改为
xxxxxxxxxx
<IfModule mod_userdir.c>
#UserDir disabled
UserDir public_html
</IfModule>
浏览格式为
xxxxxxxxxx
http://域名或IP/~username
xxxxxxxxxx
mkdir -p /virdir/
cd /virdir/
echo "This is Virtual Directory sample" >> index.html
chmod 705 index.html
配置文件中添加
xxxxxxxxxx
Alias /test "/virdir"
浏览
xxxxxxxxxx
http://域名或IP/test
即可看到虚拟目录中的页面
xxxxxxxxxx
cd /etc/sysconfig/network-scripts/
cp -p ifcfg-eth0 ifcfg-eth0:1
vim ifcfg-eth0:1
修改如下内容
xxxxxxxxxx
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.xxx.1
NETMASK=255.255.255.0
重启网络
xxxxxxxxxx
service network restart
分别创建/var/www/ip1和/var/www/ip2
xxxxxxxxxx
mkdir /var/www/ip1 /var/www/ip2
cd /var/www/ip1
echo "This is 192.168.xxx.1's web" >> index.html
cd /var/www/ip2
echo "This is 192.168.xxx.2's web" >> index.html
xxxxxxxxxx
vim /etc/httpd/conf/httpd.conf
到达文件末尾(G) 复制文件末尾最后7行(7yy) 粘贴(p)
xxxxxxxxxx
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>
删去注释并修改
xxxxxxxxxx
<VirtualHost 192.168.xxx.1>
...
DocumentRoot /var/www/ip1
...
</VirtualHost>
<VirtualHost 192.168.xxx.2>
...
DocumentRoot /var/www/ip2
...
</VirtualHost>
xxxxxxxxxx
http://192.168.xxx.1
http://192.168.xxx.2
操作同上(2)(3)(4),不过要添加Listen 端口号,在IP后加“:端口“
xxxxxxxxxx
Listen 8080
Listen 8090
...
<VirtualHost 192.168.xxx.1:8080>
...
DocumentRoot /var/www/port8080
...
</VirtualHost>
<VirtualHost 192.168.xxx.1:8090>
...
DocumentRoot /var/www/port8090
...
</VirtualHost>
xxxxxxxxxx
cd /media/RHEL-6.6\ Server.i386/Packages
rpm -ivh bind-9.8.2-0.30.rc1.el6.i686.rpm
修改配置文件
xxxxxxxxxx
vim /etc/named.conf
修改如下内容
xxxxxxxxxx
listen on port 53 { any; }
...
allow-query { any; }
x
vim /etc/named.rfc1912.zones
复制最后11行(11yy) 粘贴(p)修改为
xxxxxxxxxx
zone "long.com" IN {
type master;
file "long.com.zone";
allow-update { none; };
};
xxxxxxxxxx
cd /var/named
cp -p named.localhost long.com.zone
vim long.com.zone
编辑如下
xxxxxxxxxx
$TTL 1D
@ IN SOA @ root.long.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
AAAA ::1
dns IN A 192.168.29.1
aaa IN A 192.168.29.1
bbb IN A 192.168.29.1
xxxxxxxxxx
mkdir /var/www/aaa /var/www/bbb
cd /var/www/aaa
echo "This is aaa web" >> index.html
cd /var/www/bbb
echo "This is bbb web" >> index.html
xxxxxxxxxx
NameVirtualhost 192.168.xxx.1
...
<VirtualHost 192.168.xxx.1>
...
ServerName aaa.long.com
DocumentRoot /var/www/aaa
...
</VirtualHost>
<VirtualHost 192.168.xxx.1>
...
ServerName bbb.long.com
DocumentRoot /var/www/bbb
...
</VirtualHost>
xxxxxxxxxx
http://aaa.long.com
http://bbb.long.com