【CentOS】配置 Apache 服务

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)

在主机中访问我们的内容地址:
【CentOS】配置 Apache 服务_第1张图片

你可能感兴趣的:(linux,apache,centos,linux)