6.4. 为 HTTP 引导配置 HTTP 服务器
您必须在服务器上安装并启用 httpd 服务,以便服务器可以在网络上提供 HTTP 引导资源。
先决条件
查找服务器的网络地址。
在以下示例中,服务器有一个 IPv4 地址为
192.168.124.2的网卡。
流程
安装 HTTP 服务器:
# dnf install httpd创建
/var/www/html/redhat目录:# mkdir -p /var/www/html/redhat- 下载 RHEL DVD ISO 文件。请参阅 所有 Red Hat Enterprise Linux 下载。
为 ISO 文件创建一个挂载点:
# mkdir -p /var/www/html/redhat/iso挂载 ISO 文件:
# mount -o loop,ro -t iso9660 path-to-RHEL-DVD.iso /var/www/html/redhat/iso将引导装载程序、内核和
initramfs从挂载的 ISO 文件复制到 HTML 目录中:# cp -r /var/www/html/redhat/iso/images /var/www/html/redhat # cp -r /var/www/html/redhat/iso/EFI /var/www/html/redhat使引导装载程序配置可编辑,并确保引导文件归运行 httpd 服务器(apache)的用户所有:
# chmod 644 /var/www/html/redhat/EFI/BOOT/grub.cfg # chown -R apache:apache /var/www/html/redhat/EFI编辑
/var/www/html/redhat/EFI/BOOT/grub.cfg文件,并将其内容替换为以下内容:set default="1" function load_video { insmod efi_gop insmod efi_uga insmod video_bochs insmod video_cirrus insmod all_video } load_video set gfxpayload=keep set timeout=60 menuentry 'Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os { linuxefi /redhat/images/pxeboot/vmlinuz inst.repo=http://192.168.124.2/redhat/iso quiet initrdefi /redhat/images/pxeboot/initrd.img } submenu 'Troubleshooting -->' { menuentry 'Install Red Hat Enterprise Linux 10.0 in text mode' --class fedora --class gnu-linux --class gnu --class os { linuxefi /redhat/images/pxeboot/vmlinuz inst.repo=http://192.168.124.2/redhat/iso inst.text quiet initrdefi /redhat/images/pxeboot/initrd.img } menuentry 'Rescue a Red Hat Enterprise Linux system' --class fedora --class gnu-linux --class gnu --class os { linuxefi /redhat/images/pxeboot/vmlinuz inst.stage2=http://192.168.124.2/redhat/iso inst.rescue quiet initrdefi /redhat/images/pxeboot/initrd.img } }在这个文件中,更新以下字符串:
- 安装 Red Hat Enterprise Linux 10.0
- 编辑版本号,以使其与您下载的 RHEL 版本匹配。
- 192.168.124.2
- 替换为服务器的 IP 地址。
在防火墙中打开端口,以允许 HTTP (80)、DHCP (67, 68)和 DHCPv6 (546, 547)流量:
# firewall-cmd --zone public \ --add-port={80/tcp,67/udp,68/udp,546/udp,547/udp}这个命令启用了临时访问,直到下次服务器重启为止。
-
可选:要启用永久访问,请在命令中添加
--permanent选项。 重新载入防火墙规则:
# firewall-cmd --reload启动 HTTP 服务器:
# systemctl enable --now httpd创建
html目录,并使其内容可读和可执行:# chmod -cR u=rwX,g=rX,o=rX /var/www/html恢复
html目录的 SELinux 上下文:# restorecon -FvvR /var/www/html