Linux下httpd服务阶段实验

发布时间:2019-12-04 14:31    浏览次数 :

[返回]

<VirtualHost 192.168.200.102:8002>

Apache2.4.4的安装及实现service和chkconfig系统控制httpd开启关闭 http://www.linuxidc.com/Linux/2013-03/81477.htm

1997022700 ; Serial

[root@rhel5 conf.d]# mount /dev/cdrom /var/www/html/yum4.修改dns主配置文件(这里使用我上次配置好的dns服务器,新添加3个域就行了)
[root@rhel5 conf.d]# vim  /var/named/chroot/etc/named.conf
[root@rhel5 conf.d]# tail -13 /var/named/chroot/etc/named.confzone "yum.com" IN{
 type master;
澳门新葡亰7802网址, file "yum.com.zone";
};
zone "88181.com" IN{
 type master;
 file "88181.com.zone";
};
zone "linuxidc.com" IN{
 type master;
 file "linuxidc.com.zone";
};
 
5.添加dns区域(zone)配置文件

</Directory>

[root@rhel5 conf.d]# htpasswd -c -b  /etc/httpd/.htpasswd news 123 Adding password for user /etc/httpd/.htpasswd#挂载光盘镜像到www.88181.com的家目录

DocumentRoot /var/www/virt2

[root@rhel5 named]# vim yum.com.zone
[root@rhel5 named]# cat yum.com.zone
$TTL 86400
@      IN      SOA    www.yum.com. root  (
2013080803 ; Serial
28800      ; Refresh
14400      ; Retry
3600000    ; Expire
86400 )    ; Minimum
@      IN      NS      www.yum.com.
@      IN      A      10.0.1.8
www    IN      A      10.0.1.8#88181.com配置文件

<Directory "/var/www/virt1">

[root@rhel5 named]# service named restart
停止 named:                                              [确定]
启动 named:                                              [确定]#重启httpd服务

<VirtualHost 192.168.200.102:80>

[root@rhel5 html]# service httpd restart
停止 httpd:                                              [失败]
启动 httpd:                                              [确定]

order deny,allow

[root@rhel5 named]# cd /var/www/html/
[root@rhel5 html]# mkdir yum 88181 linuxidc
[root@rhel5 conf.d]# mkdir /usr/html#添加标志性文件

[[email protected] etc]# vim named.rfc1912.zones

实验需求
配置基于域名的虚拟主机,必须用以下域名访问
www.88181.com
www.linuxidc.com
要求这两个虚拟站点分别存放日志文件
只有访问www.88181.com/news时,要求输入账户news密码123后能看到/usr/html目录下test.htm网页内容
只有88181.com有news别名,linuxidc.com没有news别名
配置只允许网段中一台主机能访问www.linuxidc.com
配置仅不允许能访问linuxidc的那台主机访问www.88181.com
 
服务器端
1.安装所需的软件包
[root@rhel5 ~]# yum install httpd -y2.添加虚拟主机的配置文件
[root@rhel5 ~]# cd /etc/httpd/conf.d/
[root@rhel5 conf.d]# vim vhost.conf
[root@rhel5 conf.d]# vim vhost.conf
[root@rhel5 conf.d]# cat vhost.confNameVirtualHost 10.0.1.8:80    #澳门新葡亰平台游戏,指定主机ip和监听端口
<VirtualHost 10.0.1.8:80>
    DocumentRoot /var/www/html/yum    #虚拟主机的文件家目录
    ServerName www.yum.com              #虚拟主机的域名
    ErrorLog logs/yum.com-error_log      #虚拟主机的日志文件
    CustomLog logs/yum.com-access_log common
</VirtualHost>
<VirtualHost 10.0.1.8:80>
    DocumentRoot /var/www/html/88181
    ServerName www.88181.com
    alias  /news  /usr/html          #设置别名
    <Directory /usr/html>              #用户认证
      AuthName  "please input password "
      AuthType  Basic
      AuthUserFile  /etc/httpd/.htpasswd
澳门新葡亰平台官网,      require user  news
    </Directory>
    <Directory  /var/www/html/88181>
      Order deny,allow        #访问控制
      Deny from 10.0.1.238
    </Directory>
    ErrorLog logs/88181.com-error_log
    CustomLog logs/88181.com-access_log common
</VirtualHost>
<VirtualHost 10.0.1.8:80>
    DocumentRoot /var/www/html/linuxidc
    ServerName www.linuxidc.com
    <Directory  /var/www/html/linuxidc>
        Order allow,deny
        Allow from 10.0.1.238
  </Directory>
    ErrorLog logs/linuxidc.com-error_log
    CustomLog logs/linuxidc.com-access_log common
</VirtualHost>
 
3.添加所需要的目录和文件夹
#创建各个虚拟主机的根目录

www2 IN A 192.168.200.102

httpd进程与线程理解总结 http://www.linuxidc.com/Linux/2013-05/85163.htm

[[email protected] www]# elinks --dump

澳门新葡亰平台游戏 1

ServerName station1.example.com

[root@rhel5 html]# echo "this is a yum" >yum/index.html
[root@rhel5 html]# echo "this is a 88181" >88181/index.html
[root@rhel5 html]# echo "this is a linuxidc" >linuxidc/index.html
[root@rhel5 conf.d]# echo "this is a 88181 news" >/usr/html/index.html#添加news目录用户认知

/usr/sbin/httpd

客户端
#修改默认dns服务器
[root@localhost ~]# vim /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf
nameserver 10.0.1.8#使用elinks命令简单测试是否能查看相应域名中的内容
[root@localhost ~]# elinks --dump www.linuxidc.com
this is a linuxidc
[root@localhost ~]# elinks --dump www.88181.com
this is a 88181
[root@localhost ~]# elinks --dump www.yum.com
this is a yum

options -Indexes -Followsymlinks

[root@rhel5 named]# vim 88181.com.zone
[root@rhel5 named]# cat 88181.com.zone
$TTL 86400
@      IN      SOA    www.88181.com. root  (
2013080803 ; Serial
28800      ; Refresh
14400      ; Retry
3600000    ; Expire
86400 )    ; Minimum
@      IN      NS      www.88181.com.
@      IN      A      10.0.1.8
www    IN      A      10.0.1.8#linuxidc.com配置文件
[root@rhel5 named]# vim linuxidc.com.zone
[root@rhel5 named]# cat linuxidc.com.zone

[[email protected] named]# cp -p localhost.zone baidu.zone

$TTL 86400
@      IN      SOA    www.linuxidc.com. root  (
2013080803 ; Serial
28800      ; Refresh
14400      ; Retry
3600000    ; Expire
86400 )    ; Minimum
@      IN      NS      www.linuxidc.com.
@      IN      A      10.0.1.8
www    IN      A      10.0.1.8
6.重启服务
#重启dns服务

www3 IN A 192.168.200.102

推荐阅读:

</VirtualHost>

[root@rhel5 conf.d]# cd /var/named/chroot/var/named/
[root@rhel5 named]# cp -a sw.com.zone yum.com.zone
[root@rhel5 named]# cp -a sw.com.zone 88181.com.zone
[root@rhel5 named]# cp -a sw.com.zone linuxidc.com.zone#yum.com配置文件

Server: 192.168.200.102

为本网卡配置多个IP

限制方法一:

[[email protected] www]# service httpd restart

HTTP的配置文件

Server: 192.168.200.102

order deny,allow

deny from all

allow-update { none; };

[[email protected] ~]# yum -y install bind bind-chroot caching-nameserver

New password:

[[email protected] named]# cp -p named.local named.baidu

[[email protected] www]# htpasswd -cm /etc/httpd/.htpasswd bob

AuthName "Crushlinux"

@ IN NS www1.baidu.com

一.生成身份认证的数据库

// query-source-v6 port 53;

HTTP介绍

这个是语法,与<VirtualHost 192.168.0.254:80>对应,表示结束。

<VirtualHost 192.168.200.102:8001>

15M ; retry

ServerName www2.baidu.com

NameVirtualHost 192.168.200.102:8002

Name: www3.baidu.com

dump-file "/var/named/data/cache_dump.db";

定义虚拟主机站点的访问控制,

file "named.zero";

在linux下面实现web服务,通常使用Apache来实现,Apache一直是Internet上面最流行的web服务器

-c 创建 -m md5的加密

一:搭建dns服务器并测试

allow-update { none; };

[[email protected] www]# elinks --dump

测试:

NameVirtualHost 192.168.200.102:80

HTTP的脚本

[[email protected] etc]# cd /var/named/chroot/var/named/

</Directory>

ServerAlias www3.baidu.com

AuthUserFile /etc/httpd/.htpasswd

order allow,deny

[[email protected] named]# nslookup www3.baidu.com

DocumentRoot /var/www/virt2

Address: 192.168.200.102#53

Hello I am www1

Server: 192.168.200.102

HTTP的端口

HTTP的守护进程

allow-update { none; };

};

allow-query { 192.168.200.0/24; };

allow-query-cache { any; };

</VirtualHost>

options -Indexes -Followsymlinks

[[email protected] www]# elinks --dump

本服务器IP:192.168.200.102

1W ; expiry

[[email protected] www]# elinks --dump

zone "." IN {

Hello I am www1

type master;

jack:$apr1$nO7oG/..$hscIaM692G043iZmr5CR51

</VirtualHost>

recursion yes;

Re-type new password:

require valid-user

Server: 192.168.200.102

file "baidu.zone";

</VirtualHost>

ServerName www2.baidu.com

options -Indexes -Followsymlinks

这个是语法,与<Directory /var/www/virt1>对应,表示结束。

file "data/named.run";

关于HTTP这个服务的属性

Hello I am www1

基于域名,基于IP,基于端口的虚拟主机。

[[email protected] www]# ifconfig eth0 192.168.200.102

DocumentRoot /var/www/virt1

zone "baidu.com" IN {

[[email protected] named]# nslookup www1.baidu.com

Address: 192.168.200.102#53

</VirtualHost>

135 Listen 192.168.200.102:8002

DocumentRoot /var/www/virt2

Adding password for user jack

DocumentRoot /var/www/virt1

nameserver 192.168.200.102

[[email protected] named]# vim named.baidu

deny from all

<VirtualHost 192.168.200.102:80>

<Directory "/var/www/virt2">

但是第二次创建用户的时候不要使用-c的参数,否则会覆盖前面的用户的。


</VirtualHost>

HTTP的全名为Hyper Text Transfer Protocol(超文本传输协议)

ServerAlias server1.example.com

<Directory "/var/www/virt1">

match-clients { 192.168.200.0/24; };

AuthUserFile /etc/httpd/.htpasswd

New password:

102.200.168.192.in-addr.arpa name = www3.baidu.com.

</Directory>

[[email protected] www]# service httpd restart

虚拟主机站点的根目录,

Require user bob jack

AuthType basic

logging {

[[email protected] etc]# cp -p named.caching-nameserver.conf named.conf

NameVirtualHost 192.168.0.254:80

<VirtualHost 192.168.200.102:80>

134 Listen 192.168.200.102:8001

AuthType Basic

[[email protected] etc]# vim named.conf

浏览器测试:

Address: 192.168.200.102

[[email protected] www]# elinks --dump

102.200.168.192.in-addr.arpa name = www1.baidu.com.

2.限制用户

[[email protected] named]# vim /etc/resolv.conf

/etc/init.d/httpd

ServerName www2.baidu.com

allow from 192.168.200.102

<Directory "/var/www/virt1">

[[email protected] www]# service httpd restart

[[email protected] ~]# yum -y install httpd

@ IN SOA www1.baidu.com. root.baidu.com. (

// query-source port 53;

分别建立了一个测试页面:

$TTL 86400

Require vaid-user

};

statistics-file "/var/named/data/named_stats.txt";

match-destinations { any; };

[[email protected] www]# vi /var/www/virt1/.htaccess

// randomization

IN AAAA ::1

认证时候的名字

关于http服务语法参数的解释:

第一个虚拟主机的站点,

ServerName www1.baidu.com

channel default_debug {

下一篇:没有了