使用yum源安装

[[email protected]~]#yum install -y httpd

使用yum源安装

[[email protected]~]#yum install -y httpd

CentOS/Linux上yum安装Apache服务

查看httpd的安装文件

[[email protected] ~]# whereis httpd

CentOS/Linux上yum安装Apache服务

查看/etc/httpd下的配置文件文件

[[email protected] ~]# ll /etc/httpd/

CentOS/Linux上yum安装Apache服务

修改apache的配置文件/etc/httpd/中的conf/httpd.conf文件

[[email protected] ~]#cd /etc/httpd/conf

[[email protected] conf]#ll

CentOS/Linux上yum安装Apache服务

编辑httpd.conf文件

[[email protected] conf]#vim httpd.conf

找到默认的#ServerName www.example.com:80

CentOS/Linux上yum安装Apache服务

修改默认的ServerName为

CentOS/Linux上yum安装Apache服务

也可以更改其默认监听的端口

查找该文件中的Listen属性

CentOS/Linux上yum安装Apache服务

需要时可自定义更改

保存,退出

查看httpd的状态

[[email protected] conf]# service httpd status

CentOS/Linux上yum安装Apache服务

httpd还处于为启动状态

启动httpd

[[email protected] conf]# service httpd start

CentOS/Linux上yum安装Apache服务

再次查看状态

[[email protected] conf]# service httpd status

CentOS/Linux上yum安装Apache服务

启动成功

添加httpd开机自启

通过yum源安装的httpd的命令会自动添加到systemctl(Linux命令)中

可以直接使用enable和disable进行控制httpd的开机启动状态

设置允许httpd开机启动

[[email protected] ~]# systemctl enable httpd.service

CentOS/Linux上yum安装Apache服务

可以重启服务器进行测试

注意:生产环境若有运行的服务切勿重启

查看Apache的状态

[[email protected] ~]# service httpd status

CentOS/Linux上yum安装Apache服务

Apache处于关闭状态

重启服务器

[[email protected] ~]# reboot

CentOS/Linux上yum安装Apache服务

等待服务器重启之后再查看Apache的状态

[[email protected] ~]# service httpd statusCentOS/Linux上yum安装Apache服务

设置Apache开机自启成功

设置禁止httpd开机启动

[[email protected] ~]# systemctl disable httpd.service

CentOS/Linux上yum安装Apache服务

[[email protected]host ~]# service httpd statusCentOS/Linux上yum安装Apache服务

重启服务器

[[email protected] ~]# reboot

CentOS/Linux上yum安装Apache服务

等待服务器重启之后再查看Apache的状态

[[email protected] ~]# service httpd status

CentOS/Linux上yum安装Apache服务

Apache没有进行开机启动,设置Apache禁止开机启动成功

httpd相关命令

service httpd status 状态

service httpd start 启动

service httpd restart 重新启动

service httpd stop 停止服务

 

 

相关文章:

  • 2021-11-06
  • 2021-11-06
  • 2021-11-28
  • 2021-06-25
  • 2021-05-22
  • 2022-12-23
  • 2021-08-21
  • 2022-03-09
猜你喜欢
  • 2022-02-07
  • 2022-02-19
  • 2021-09-30
  • 2021-09-30
  • 2021-11-06
  • 2021-11-03
相关资源
相似解决方案