centos 安装 apache
跟新:(可选) yum -y update
#netstat -an | grep 80 (检查端口是否被占用)
# yum install httpd httpd-devel 或者 yum -y install httpd httpd-manual httpd-devel mod_ssl mod_perl mod_auth_mysql
# systemctl enable httpd.service (开机自启动设置)
# systemctl list-unit-files | grep httpd (查看是否开机自启动)
# systemctl start httpd.service (启动服务)
# curl http://127.0.0.1 (检查是否成功)
=============================
防火墙中打开 80 端口:
# firewall-cmd --zone=public --add-port=80/tcp --permanent (持久化开启80端口)
# firewall-cmd –reload
------------------------
其他补充知识:
查看版本: firewall-cmd --version
显示状态: firewall-cmd --state
查看所有打开的端口: netstat -anp
开启防火墙 systemctl start firewalld
关闭防火墙 systemctl stop firewalld
查询指定端口是否已开
firewall-cmd --query-port=80/tcp
systemctl disable firewald.service (永久关闭防火墙)
systemctl enable firewald.service (永久开启防火墙)
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动