使用yum源安装
[[email protected]~]#yum install -y httpd
使用yum源安装
[[email protected]~]#yum install -y httpd
查看httpd的安装文件
[[email protected] ~]# whereis httpd
查看/etc/httpd下的配置文件文件
[[email protected] ~]# ll /etc/httpd/
修改apache的配置文件/etc/httpd/中的conf/httpd.conf文件
[[email protected] ~]#cd /etc/httpd/conf
[[email protected] conf]#ll
编辑httpd.conf文件
[[email protected] conf]#vim httpd.conf
找到默认的#ServerName www.example.com:80
修改默认的ServerName为
也可以更改其默认监听的端口
查找该文件中的Listen属性
需要时可自定义更改
保存,退出
查看httpd的状态
[[email protected] conf]# service httpd status
httpd还处于为启动状态
启动httpd
[[email protected] conf]# service httpd start
再次查看状态
[[email protected] conf]# service httpd status
启动成功
添加httpd开机自启
通过yum源安装的httpd的命令会自动添加到systemctl(Linux命令)中
可以直接使用enable和disable进行控制httpd的开机启动状态
设置允许httpd开机启动
[[email protected] ~]# systemctl enable httpd.service
可以重启服务器进行测试
注意:生产环境若有运行的服务切勿重启
查看Apache的状态
[[email protected] ~]# service httpd status
Apache处于关闭状态
重启服务器
[[email protected] ~]# reboot
等待服务器重启之后再查看Apache的状态
[[email protected] ~]# service httpd status
设置Apache开机自启成功
设置禁止httpd开机启动
[[email protected] ~]# systemctl disable httpd.service
[[email protected]host ~]# service httpd status
重启服务器
[[email protected] ~]# reboot
等待服务器重启之后再查看Apache的状态
[[email protected] ~]# service httpd status
Apache没有进行开机启动,设置Apache禁止开机启动成功
httpd相关命令
service httpd status 状态
service httpd start 启动
service httpd restart 重新启动
service httpd stop 停止服务