阿里云ECS服务器:CentOS安装Apache服务

Apache软件包和服务称为httpd。

1、要安装软件包,运行命令:

sudo yum install httpd

2、安装完成后,启用并启动Apache服务:

sudo systemctl enable httpd

sudo systemctl start httpd

3、检查Apache服务的状态和版本:

sudo systemctl status httpd

输出:

httpd.service - The Apache HTTP Server

 Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)

 Active: active (running) since Thu 2018-04-26 07:13:07 UTC; 11s ago

   Docs: man:httpd(8)

         man:apachectl(8)

 

Main PID: 3049 (httpd)

 Status: "Total requests: 0; Current requests/sec: 0; Current traffic:  0 B/sec"

 CGroup: /system.slice/httpd.service

         ├─3049 /usr/sbin/httpd -DFOREGROUND

         ├─3050 /usr/sbin/httpd -DFOREGROUND

         ├─3051 /usr/sbin/httpd -DFOREGROUND

         ├─3052 /usr/sbin/httpd -DFOREGROUND

         ├─3053 /usr/sbin/httpd -DFOREGROUND

         └─3054 /usr/sbin/httpd -DFOREGROUND

查看Apache版本:

sudo httpd -v

输出:

Server version: Apache/2.4.39 (CentOS)

Server built:  Feb 08 2020 20:39:16

4、最后,要验证安装,在浏览器输入您的服务器IP地址http://YOUR_IP(公网IP),出现下图界面:

阿里云ECS服务器:CentOS安装Apache服务_第1张图片

此外:
使用systemctl管理Apache服务

要停止Apache服务:

sudo systemctl stop httpd

要再次启动::

sudo systemctl start httpd

重新启动Apache服务:

$sudo systemctl restart httpd

在进行一些配置更改后重新加载Apache服务:

$sudo systemctl reload httpd

如果您想禁用Apache服务以在启动时启动:

$sudo systemctl disable httpd

并重新启用它:

$sudo systemctl enable httpd

你可能感兴趣的:(服务器部署)