天天看点

Red Hat 7 Apache 安装与配置Apache服务安装与配置

Apache服务安装与配置

检测主机中是否安装Apache

rpm -qa | grep httpd
           

安装Apache命令

yum -y install httpd
           
如果安装错误请参考 Yum配置安装 https://blog.csdn.net/qq_39906884/article/details/84139028

查看 Apache 状态

systemctl status httpd.service
           
Red Hat 7 Apache 安装与配置Apache服务安装与配置

启动 Apache

再次查看 Apache 状态

systemctl start httpd.service
systemctl status httpd.service
           
Red Hat 7 Apache 安装与配置Apache服务安装与配置

设置 Apache 开机启动

systemctl enable httpd.service
           

查看本机的IP地址

打开浏览器, 网址输入本机ip地址或者localhost, 为以下内容说明正确打开了 Apache 服务

Red Hat 7 Apache 安装与配置Apache服务安装与配置

打开防火墙

Red Hat 7 Apache 安装与配置Apache服务安装与配置

http 服务打勾

Red Hat 7 Apache 安装与配置Apache服务安装与配置

在另一台主机上打开浏览器网址填写服务器ip地址 , 可以查看与服务器一样的内容

Red Hat 7 Apache 安装与配置Apache服务安装与配置

文件介绍

Apache服务器配置文件: /etc/httpd/conf/httpd.conf

Web站点的相关文件目录: /var/www

Web站点根目录: /var/www/html

Web站点的日志文件目录: /var/log/httpd

在Web站点根目录: /var/www/html下放入写好的index.html文件, 然后然后再浏览器输入服务器IP, 显示index.html内容

设置个人Web站点配置

修改 /etc/httpd/conf.d/userdir.conf 文件

将17行的 UserDir disabled 注释, 解除24行UserDir public_html 的注释

Red Hat 7 Apache 安装与配置Apache服务安装与配置

设置SELinux打开对主目录的访问(加**-P**选项代表永久打开)

setsebool -P httpd_enable_homedirs on
           

切换用户(用dou用户为例),

在家目录创建public_html目录,

修改家目录权限

su - dou
chmod 755 -R /home/dou
           

随后重启Apache服务

systemctl restart httpd.service 
           

在浏览器输入 服务器IP/~dou, 显示出来index.html的网页内容

Red Hat 7 Apache 安装与配置Apache服务安装与配置

继续阅读