步骤1:更新CentOS 8软件包
建议,通常在开始安装之前先更新软件包是一个好的习惯。 因此,登录到您的服务器并运行以下命令。
[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf update
步骤2:在CentOS 8上安装Apache Web 服务器
随着系统软件包的更新,下一步是安装Apache Web 服务器,一些关键的工具和实用程序将运行下面这条命令。
[linuxidc@localhost ~/www.linuxidc.com]$sudo dnf install httpd httpd-tools
安装完成后,使用以下命令启用Apache在系统启动时自动启动。
[linuxidc@localhost ~/www.linuxidc.com]$sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
接下来,通过运行命令启动Apache服务。
[linuxidc@localhost ~/www.linuxidc.com]$sudo systemctl start httpd
要确认Apache Web服务是否正在运行,请运行命令。
[linuxidc@localhost ~/www.linuxidc.com]$sudo systemctl status httpd
输出如下:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Active: active (running) since Wed 2020-02-26 07:07:23 EST; 2min 15s ago
Docs: man:httpd.service(8)
Main PID: 85860 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 23820)
Memory: 25.2M
CGroup: /system.slice/httpd.service
├─85860 /usr/sbin/httpd -DFOREGROUND
├─85862 /usr/sbin/httpd -DFOREGROUND
├─85863 /usr/sbin/httpd -DFOREGROUND
lines 1-12