小编给大家分享一下RHEL 8如何配置Apache Web服务,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

Apache服务因其开源、跨平台应用、支持多种网页编程语言、模块化设计 、运行稳定、良好的安全性等优点,被广泛应用于承载Web服务,而其与Linux、PHP、MySQL等组件相结合后,更能充分发挥出其独具特色的优点,是小型网站搭建的较优选择。

环境

Red Hat Enterprise Linux release 8.0 VMware Workstation Pro 14

搭建步骤

[root@localhost~]#yuminstall-yhttpd[root@localhost~]#systemctlstarthttpd[root@localhost~]#iptables-F[root@localhost~]#systemctlstopfirewalld[root@localhost~]#systemctldisablefirewalldRemoved/etc/systemd/system/multi-user.target.wants/firewalld.service.Removed/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@localhost~]#setenforce0[root@localhost~]#ifconfigens33:flags=4163mtu1500inet192.168.10.118netmask255.255.255.0broadcast192.168.10.255inet6fe80::e09a:769b:83f0:8efaprefixlen64scopeid0x20ether00:50:56:34:0d:74txqueuelen1000(Ethernet)RXpackets1959bytes1690200(1.6MiB)RXerrors0dropped0overruns0frame0TXpackets1245bytes120922(118.0KiB)TXerrors0dropped0overruns0carrier0collisions0lo:flags=73mtu65536inet127.0.0.1netmask255.0.0.0inet6::1prefixlen128scopeid0x10looptxqueuelen1000(LocalLoopback)RXpackets0bytes0(0.0B)RXerrors0dropped0overruns0frame0TXpackets0bytes0(0.0B)TXerrors0dropped0overruns0carrier0collisions0virbr0:flags=4099mtu1500inet192.168.122.1netmask255.255.255.0broadcast192.168.122.255ether52:54:00:9c:ef:c6txqueuelen1000(Ethernet)RXpackets0bytes0(0.0B)RXerrors0dropped0overruns0frame0TXpackets0bytes0(0.0B)TXerrors0dropped0overruns0carrier0collisions0

在浏览器输入 192.168.10.118 查看 Apache Web 服务状态

自定义首页内容

[root@localhost~]#echo"HELLORHEL8">/var/www/html/index.html[root@localhost~]#systemctlrestarthttpd

设置文件共享服务

[root@localhost~]#rm-rf/etc/httpd/conf.d/welcome.conf[root@localhost~]#rm-rf/var/www/html/index.html[root@localhost~]#touch/var/www/html/file{1..10}[root@localhost~]#systemctlrestarthttpd

设置端口映射

查看宿主机IP

在浏览器输入 192.168.0.7:118 测试文件共享服务状态

解决中文乱码

[root@localhost~]#touch/var/www/html/你好红帽8.txt[root@localhost~]#systemctlrestarthttpd

解决方法 在 /etc/httpd/conf/httpd.conf 配置文件中加入 IndexOptions Charset=UTF-8

[root@localhost~]#vim/etc/httpd/conf/httpd.conf316AddDefaultCharsetUTF-8317IndexOptionsCharset=UTF-8[root@localhost~]#systemctlrestarthttpd

以上是“RHEL 8如何配置Apache Web服务”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!