【CentOS】配置 Apache 服务

sh 复制代码
yum install httpd -y

# 查看是否安装成功
httpd -v
# 出现版本号表示成功

# 启动服务
systemctl start httpd

# 查看状态
systemctl status httpd
# running 即可成功
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2023-12-05 16:23:38 CST; 5s ago
     Docs: man:httpd.service(8)
 Main PID: 2595 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 4636)
   Memory: 35.9M
   CGroup: /system.slice/httpd.service
           ├─2595 /usr/sbin/httpd -DFOREGROUND
           ├─2596 /usr/sbin/httpd -DFOREGROUND
           ├─2597 /usr/sbin/httpd -DFOREGROUND
           ├─2598 /usr/sbin/httpd -DFOREGROUND
           └─2599 /usr/sbin/httpd -DFOREGROUND

12月 05 16:23:37 yuanxin.linux.com systemd[1]: Starting The Apache HTTP Server...
12月 05 16:23:38 yuanxin.linux.com systemd[1]: Started The Apache HTTP Server.
12月 05 16:23:38 yuanxin.linux.com httpd[2595]: Server configured, listening on: port 80

# 将服务设置为开机启动
systemctl enable httpd

# 将出现
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.

# 查看内容地址
ip addr

# 将出现---ens160 中的 192.168.212.129 就是我们的内网地址
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:5a:78:f6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.212.129/24 brd 192.168.212.255 scope global noprefixroute ens160
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe5a:78f6/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:46:03:15 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:46:03:15 brd ff:ff:ff:ff:ff:ff

# 访问内网地址时,如果显示无法访问,可以尝试关闭 centos 的防火墙
systemctl stop firewalld.service

# 禁止自启动
systemctl disable firewalld.service

# 查看防火墙状态
systemctl status firewalld.service

# 如果是关闭状态就算完成了
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

在主机中访问我们的内容地址:

相关推荐
影视飓风TIM12 分钟前
Linux下C语言缓冲区原理 + Git版本控制
linux·c语言·git
来者皆善32 分钟前
ZYNQ linux上使用 USB CDC ACM
linux·运维·服务器
Dawn-bit2 小时前
Linux磁盘分区与Swap和磁盘故障查询
linux·运维·服务器·网络·云计算
无足鸟ICT3 小时前
【RHCA+】$[]
linux·运维·服务器
运维技术小记4 小时前
国产化环境配置 VNC 远程桌面:麒麟 V10 实战
linux·运维·服务器
xiaoye-duck4 小时前
《Linux系统编程》Linux 系统多线程(八): C++ 高并发线程池全链路深度解析与从零手撕实现
linux·c++·线程池
寒水馨5 小时前
Linux下载、安装protobuf-v35.1(附安装包protoc-35.1-linux-x86_64.zip)
linux·运维·服务器·google·序列化·protobuf·protoc
王琦03185 小时前
Linux的文件管理
linux·运维·服务器
☆凡尘清心☆5 小时前
CentOS Stream 9 Redis 7.2.7 源码编译一键安装脚本
linux·运维·redis·centos
Android系统攻城狮5 小时前
Linux PipeWire深度解析之pw_stream_new调用流程与实战(四十二)
linux·运维·服务器·音频进阶·pipewire音频进阶