《HCIP-openEuler实验指导手册》1.2Apache主页面配置

一、配置服务器监听IP及端口

  1. 注释主配置文件“监听IP及端口”部分
cd /etc/httpd/conf
cp httpd.conf httpd.conf.bak
vim httpd.conf

可以在普通模式下搜索Listen关键字

:/Listen

按n键继续向后搜索
在这里插入图片描述

  1. 在/etc/httpd/conf.d中新建子配置文件port.conf:
touch /etc/httpd/conf.d/port.conf
echo "Listen 81" > /etc/httpd/conf.d/port.conf

touch /etc/httpd/conf.d/port.conf
echo "Listen 192.168.209.137:81" > /etc/httpd/conf.d/port.conf
  1. 重启加载httpd的配置文件
systemctl reload httpd
  1. 防火墙添加81端口
firewall-cmd --zone=public --add-port=81/tcp --permanent
firewall-cmd --reload
  1. curl命令访问81端口
curl 127.0.0.1:81

curl 192.168.209.137:81 #换成自己的IP

二、配置主页面

  1. 新建index.html测试页面
cd /var/www/html
rm -rf index.html
echo "hello,openEuler" > index.html
cat index.html
  1. 访问测试
curl 127.0.0.1:81

三、配置主页面存放目录(配置网站根目录)

  1. 更改根目录
mkdir /home/source
mv /var/www/html/index.html /home/source/
echo 'DocumentRoot "/home/source"'> /etc/httpd/conf.d/source.conf
  1. 配置目录访问权限
vim /etc/httpd/conf.d/source.conf

添加如下内容:

<Directory "/home/source">
        AllowOverride None
        #Allow open access:
        Require all granted
</Directory>

在这里插入图片描述

systemctl reload httpd
curl 127.0.0.1:81

在这里插入图片描述

最近更新

  1. TCP协议是安全的吗?

    2024-04-21 13:42:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-21 13:42:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-21 13:42:03       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-21 13:42:03       20 阅读

热门阅读

  1. 什么是关键信息基础设施及其安全保护条例

    2024-04-21 13:42:03       14 阅读
  2. 浏览器原理之本地存储

    2024-04-21 13:42:03       11 阅读
  3. 续传查询SQL不规范导致漏数的问题

    2024-04-21 13:42:03       15 阅读
  4. linux的内存管理

    2024-04-21 13:42:03       11 阅读
  5. 提升用户体验的UUID设计策略

    2024-04-21 13:42:03       19 阅读
  6. 个人网站开(九)五系统前端react

    2024-04-21 13:42:03       12 阅读
  7. PyTorch项目实战开发教程:智能家居与IoT

    2024-04-21 13:42:03       55 阅读
  8. PostCSS概述

    2024-04-21 13:42:03       33 阅读
  9. Go中的HTTP请求处理概述

    2024-04-21 13:42:03       18 阅读
  10. Golang context 原理分析

    2024-04-21 13:42:03       51 阅读