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 (检查是否成功)

 

=============================

Apache配置文件:/etc/httpd/conf/httpd.conf (可配置,网站目录,日志目录等)
Apache配置目录,其他配置文件目录:/etc/httpd/conf.d/
Apache网站根目录:/var/www/html/
Apache日志文件目录:/var/log/httpd
 

防火墙中打开 80 端口: 

# firewall-cmd --zone=public --add-port=80/tcp --permanent (持久化开启80端口)

# firewall-cmd –reload 

 

在浏览器输入公网地址:http://ip/

 

------------------------

其他补充知识:

查看版本: 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开机启动

 

 
posted @ 2019-10-29 19:54  Perry_Lee  阅读(404)  评论(0编辑  收藏  举报