【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)

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

相关推荐
A小辣椒2 天前
TShark:Wireshark CLI 功能
linux
A小辣椒2 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao3 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334663 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪3 天前
linux 拷贝文件或目录到指定的位置
linux
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
bush44 天前
嵌入式linux学习记录十四、术语
linux·嵌入式
载数而行5204 天前
Linux 11 动态监控指令top
linux
不会C语言的男孩4 天前
Linux 系统编程 · 第 8 章:进程基础
linux·c语言