Linux系统如何安装apache,和DNS服务并进行应用

实验案例:构建httpd网站服务器

  • 实验环境

某公司根据系信息化建设要求,需要构建一台独立配置的网站服务器。考虑到站点的运行效率、稳定性及可扩展性等因素,要求在CentOS7系统中构建httpd服务器,并使用httpd-2.2.17源码版本进行编译安装。

  • 需求描述

1 . 编译安装httpd服务器,需求支持动态模式扩展,地址重写、多字符集
2. 网站名称设置为www.bdqn.com,默认首页设置为index.html和index.php
3. 将/usr/shere/dpc/HTML/zh-CH/目录下的index.html复制到网站根目录下并改名为redhat
4. 在浏览器中分别访问http://www.bdqn.com/redhat与http://www.bdqn.com/查看不同的测试页面
推荐步骤:
1、编译安装httpd软件包。
1)centos先删除yum的根目录删掉。安装apache,和DNS一共需要两个映像文件。先安装DNS,需要安装这个系统的映像文件,所以不需要更改映像文件。
[root@centos01 ~]# rm -rf /etc/yum.repos.d/CentOS-*
2)挂载光盘
[root@centos01 ~]# mount /dev/cdrom /mnt/
3)安装DNS
[root@centos01 ~]# yum -y install bind bind-chroot bind-utils
4)查看安装上没有
[root@centos01 ~]# rpm -qa | grep bind
一般有7个以上表示安装上了
5)配置DNS,先清空DNS主配置文件,并 配置,然后查看有没有报错。
[root@centos01 ~]# echo “” > /etc/named.conf
[root@centos01 ~]# vim /etc/named.conf
DNS主配置文件
[root@centos01 ~]# named-checkconf /etc/named.conf
6)配置权威服务器。
[root@centos01 ~]# cat /var/named/bdqn.com.zone
配置正向解析
7)给正向解析文件控制权限,,检测正向解析文件是否错误
[root@centos01 ~]# chmod 755 /var/named/bdqn.com.zone
[root@centos01 ~]# chown named:named /var/named/bdqn.com.zone
[root@centos01 ~]# named-checkzone bdqn.com /var/named/bdqn.com.zone
zone bdqn.com/IN: loaded serial 2019102501
OK
8)开启DNS,并且打开开机自启。
[root@centos01 ~]# systemctl start named
[root@centos01 ~]# systemctl enable named
9)centos挂载光盘
虚拟机LIUNX
9)先取消挂载,在挂载。
[root@centos03 ~]# umount /mnt/
umount: /mnt/:未挂载
[root@centos03 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 写保护,将以只读方式挂载
10)进入/mnt/,ls查看
发现有很多东西
11)将httpd-2.2.17.tar.gz复制到程序目录/usr/src/,在进入usr/src/,解压。
[root@centos01 mnt]# cp httpd-2.2.17.tar.gz /usr/src
[root@centos01 mnt]# cd /usr/src/
[root@centos01 src]# tar zxvf httpd-2.2.17.tar.gz
12)进入解压过的目录中,配置,指定将httpd服务程序安装到/usr/local/httpd,启动动态加载模块支持,启用网页地址重写功能,启用字符集支持,启用CGI脚本程序支持。
[root@centos01 src]# cd /usr/src/httpd-2.2.17/
[root@centos01 httpd-2.2.17]# ./configure --prefix=/usr/local/httpd --enable-so --enable-rewrite --enable-charset-lite --enable-cgi
13)编译及安装
编译[root@centos01 httpd-2.2.17]# make
安装[root@centos01 httpd-2.2.17]# make install
14)优化执行路径,差不多是减少命令。
[root@centos01 ~]# ln -s /usr/local/httpd/bin/* /usr/local/bin
15)将apachectl脚本复制为/etc/init.d/httpd下,配置执行权限。
[root@centos01 ~]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@centos01 ~]# chmod +x /etc/init.d/httpd
16)添加httpd系统服务
[root@centos01 ~]# vi /etc/init.d/httpd
#!/bin/sh
#chkconfig: 35 80 21
#description:apach server
17)将httpd添加为系统服务
[root@centos01 ~]# chkconfig --add httpd
18)设置httpd服务开机自启动,查看httpd服务的自启动状态。
[root@centos01 ~]# systemctl is-enabled httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd --level=5
enabled
19)检查apache服务配置文件是否有错误。
[root@centos01 ~]# apachectl -t
httpd: Could not reliably determine the server’s fully qualified domain name, using fe80::20c:29ff:fe16:7578 for ServerName
Syntax OK
20)启动httpd服务,并查看
[root@centos01 ~]# systemctl start httpd
[root@centos01 ~]# netstat -anpt | grep httpd
tcp6 0 0 :::80 ::? LISTEN 53788/httpd
21)使用win7访问192.168.100.10
这是哪个网页
2、测试Web站点。
1)初始测试
哪个页面
2)更给访问文件后
更改访问文件后

3)多了个相同页面不同访问地址。
多了个相同也面不同地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值