yum安装
## 先yum list看看有没有你可以的包
yum list httpd
## 如果有的话,比如我用x86_64版,就可以安装
yum install httpd.x86_64
配置、启动Apache
1.httpd.conf是主配置文件,你可以按需更改,一般来说可能需要自定义端口,那么就vim修改httpd.conf文件的监听端口,改为你希望的
![2743275-76ab61f49d322c12.png](https://upload-images.jianshu.io/upload_images/2743275-76ab61f49d322c12.png)
image.png
查找httpd.conf文件位置
# find / -name httpd.conf
2.启动、关闭、重启
# ./apachectl start
# ./apachectl stop
# ./apachectl restart
一般此文件在 /usr/sbin 目录下
Apache设置为Linux系统服务,并开机启动
1.将链接apachectl 复制到系统启动目录下并命名为httpd
# cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
到此,其实已经可以使用service httpd start等命令,但在linux服务列表还没有注册
2.使用chkconfig来注册apache服务,并其可以在linux的服务列表中看到(chkconfig –list)
2.1.在init.d的httpd链接文件中第2行添加如下注释,并wq保存退出
# vim /etc/rc.d/init.d/httpd
![2743275-f071311a9668f590.png](https://upload-images.jianshu.io/upload_images/2743275-f071311a9668f590.png)
image.png
2.2.将httpd配置自启并加入linux服务监控
# chkconfig --add httpd
可以使用:
# service httpd start
# service httpd stop
# service httpd restart