我爱编程

03.centos7安装Apache

2017-12-26  本文已影响0人  Lv_0
  1. LAMP就是Linux系统下搭建的Apache,MySQL,PHP构成的web服务器;
  2. 安装方式:源代码安装,rpm包安装,yum安装

  1. 检测是否安装了apache,命令:rpm -qa httpd,无返回则未安装
image.png
  1. 运行yum命令:yum install httpd -y进行安装
image.png
  1. 再次检测,安装成功
image.png

  1. 配置文件路径:/etc/httpd/conf/httpd.conf
image.png
  1. vi命令,配置端口(在ServerName www.example.com:80下插入ServerName localhost:80,保存并退出),配置前备份
test20.gif
  1. 启动apache(配置apache后,要重启apache)
启动方式1:
systemctl start httpd.service 启动
systemctl stop httpd.service 停止
systemctl restart httpd.service 重启
ps -ef|grep httpd 查看进程
启动方式2:
service httpd start 启动
service httpd stop 停止
service httpd restart 重启
service httpd status 状态
启动方式3:
httpd 启动
httpd -k stop 停止
chkconfig httpd on 设置开机启动
启动方式4:
apachectl start 启动
apachectl stop 停止
apachectl restart 重启
image.png
  1. 配置防火墙,命令:iptables -I INPUT -p tcp --dport 80 -j ACCEPT
image.png
  1. 测试apache服务,在浏览器输入:http://服务器ip,查看是否连通(ip地址可通过ifconfig命令查看)
image.png
上一篇 下一篇

猜你喜欢

热点阅读