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

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

相关推荐
别或许17 小时前
在centos系统下,安装MYSQL
linux·mysql·centos
丁丁丁梦涛17 小时前
CentOS修改MySQL数据目录后重启失败的问题及解决方案
linux·mysql·centos
黑马金牌编程17 小时前
Jenkins的Linux与window部署方式
linux·运维·windows·jenkins·持续集成·cicd
web安全工具库17 小时前
告别刀耕火种:用 Makefile 自动化 C 语言项目编译
linux·运维·c语言·开发语言·数据库·算法·自动化
DechinPhy17 小时前
Ubuntu挂载新硬盘
linux·运维·服务器·ubuntu
lht63193561217 小时前
Ubuntu Server 系统安装图形界面远程工具(RDP)
linux·运维·ubuntu
云计算练习生18 小时前
linux shell编程实战 02 变量与交互式输入
linux·运维·shell编程·shell 变量
Dovis(誓平步青云)18 小时前
《简易制作 Linux Shell:详细分析原理、设计与实践》
linux·运维·服务器
weixin_3077791318 小时前
在Linux服务器上使用Jenkins和Poetry实现Python项目自动化
linux·开发语言·python·自动化·jenkins
爱宇阳18 小时前
Linux 教程:如何查看服务器当前目录中的文件
linux·运维·github