一、 实验内容 配置Web服务器,可以从客户端访问服务器,打开网页。 二、 服务器端设置 1、 配置DNS服务器,要求能够解析域名。 2、 配置Web 服务器 (1) [root@localhost named]# cd /run/media/root/RHEL-7.2\ Server.x86_64/Packages/ //虚拟机路径 [root@localhost named]# cd /mnt/RHEL-7.2\ Server.x86_64/Packages/ //云平台安装路径 [root@localhost Packages]# ls httpd* httpd-2.4.6-40.el7.x86_64.rpm httpd-devel-2.4.6-40.el7.x86_64.rpm httpd-manual-2.4.6-40.el7.noarch.rpm httpd-tools-2.4.6-40.el7.x86_64.rpm 安装标红色的三个程序包。 (2)[root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.x86_64.rpm 警告:httpd-2.4.6-40.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY 错误:依赖检测失败: /etc/mime.types 被 httpd-2.4.6-40.el7.x86_64 需要 httpd-tools = 2.4.6-40.el7 被 httpd-2.4.6-40.el7.x86_64 需要 libapr-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.x86_64 需要 libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.x86_64 需要 可以看到缺少mime.types文件。缺少http-tools文件,apr和aprutils文件,一个一个安装所需软件包。首先安装mailcap软件包添加mime.types文件。 (3)[root@localhost Packages]# ls mailcap* mailcap-2.1.41-2.el7.noarch.rpm [root@localhost Packages]# rpm -ivh mailcap-2.1.41-2.el7.noarch.rpm (4)[root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.x86_64.rpm 警告:httpd-2.4.6-40.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY 错误:依赖检测失败: httpd-tools = 2.4.6-40.el7 被 httpd-2.4.6-40.el7.x86_64 需要 libapr-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.x86_64 需要 libaprutil-1.so.0()(64bit) 被 httpd-2.4.6-40.el7.x86_64 需要 缺少apr软件和apr-util软件。 (5)安装apr和apr-util软件,型号为x86_64。 [root@localhost Packages]# ls apr* apr-1.4.8-3.el7.i686.rpm apr-util-1.5.2-6.el7.i686.rpm apr-1.4.8-3.el7.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm apr-devel-1.4.8-3.el7.i686.rpm apr-util-devel-1.5.2-6.el7.i686.rpm apr-devel-1.4.8-3.el7.x86_64.rpm apr-util-devel-1.5.2-6.el7.x86_64.rpm [root@localhost Packages]# rpm -ivh apr-1.4.8-3.el7.x86_64.rpm [root@localhost Packages]# rpm -ivh apr-util-1.5.2-6.el7.x86_64.rpm (6)先安装httpd-tools软件包,不然仍会出错。 [root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.x86_64.rpm 警告:httpd-2.4.6-40.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID fd431d51: NOKEY 错误:依赖检测失败: httpd-tools = 2.4.6-40.el7 被 httpd-2.4.6-40.el7.x86_64 需要 [root@localhost Packages]# rpm -ivh httpd-tools-2.4.6-40.el7.x86_64.rpm (7)安装其他软件包 [root@localhost Packages]# rpm -ivh httpd-2.4.6-40.el7.x86_64.rpm [root@localhost Packages]# rpm -ivh httpd-manual-2.4.6-40.el7.noarch.rpm (8)进入配置文件开始配置 [root@localhost Packages]# vi /etc/httpd/conf/httpd.conf
(9)再次使用apachectl configtest命令查看,检查出错,缺少MPM模块 [root@localhost Packages]# apachectl configtest AH00534: httpd: Configuration error: No MPM loaded. 进入配置文件修改最后两句为: [root@localhost Packages]# vi /etc/httpd/conf/httpd.conf LoadModule mpm_prefork_module modules/mod_mpm_prefork.so Include conf.modules.d/*.conf 同时打开日志。 (10)再次检查,检查通过了即开启httpd服务 [root@localhost Packages]# apachectl configtest [Mon Apr 09 23:25:12.255702 2018] [so:warn] [pid 13061] AH01574: module mpm_prefork_module is already loaded, skipping Syntax OK [root@localhost Packages]# systemctl start httpd.service (11)打开日志查看下错误信息,缺少文件 [root@localhost logs]# cat /etc/httpd/logs/error_log [Tue Apr 10 12:29:49.557017 2018] [core:notice] [pid 19247] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Tue Apr 10 12:29:49.557123 2018] [mime:error] [pid 19247] (2)No such file or directory: AH01597: could not open mime types config file /etc/httpd/conf/mime.types. AH00016: Configuration Failed (12)把文件复制到/etc/httpd/conf/mime.types. [root@localhost ~]# cp /etc/mime.types /etc/httpd/conf/ [root@localhost ~]# cd /etc/httpd/conf/ [root@localhost conf]# ls httpd.conf magic mime.types [root@localhost conf]# 三、再次启动httpd,没有问题,可以启动了! [root@localhost conf]# systemctl start httpd.service [root@localhost conf]# 四、将网页保存到var/www/html/目录中 [root@localhost conf]# echo This is www.sh.com >/var/www/html/index.html 五、打开浏览器输入网址
|