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

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

  1. 注释主配置文件"监听IP及端口"部分
bash 复制代码
cd /etc/httpd/conf
cp httpd.conf httpd.conf.bak
vim httpd.conf

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

bash 复制代码
:/Listen

按n键继续向后搜索

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

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

bash 复制代码
curl 192.168.209.137:81 #换成自己的IP

二、配置主页面

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

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

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

添加如下内容:

bash 复制代码
<Directory "/home/source">
        AllowOverride None
        #Allow open access:
        Require all granted
</Directory>
bash 复制代码
systemctl reload httpd
curl 127.0.0.1:81
相关推荐
ALLSectorSorft5 小时前
上门服务小程序会员系统框架设计
小程序·apache
杨过姑父6 小时前
部署开源版禅道,修改apache端口无效解决
bug·apache·软件工程·issue
酷爱码7 小时前
Spring Boot 整合 Apache Flink 的详细过程
spring boot·flink·apache
黑客老李1 天前
JavaSec | SpringAOP 链学习分析
java·运维·服务器·开发语言·学习·apache·memcached
临水逸1 天前
可视化大屏工具对比:GoView、DataRoom、积木JimuBI、Metabase、DataEase、Apache Superset 与 Grafana
apache·grafana
SelectDB技术团队1 天前
Apache Doris + MCP:Agent 时代的实时数据分析底座
人工智能·数据挖掘·数据分析·apache·mcp
田猿笔记1 天前
Apache DolphinScheduler 和 Apache Airflow 对比
apache
酷爱码1 天前
在 Linux 中修改 Apache HTTP Server(httpd)默认端口的完整指南
linux·http·apache
学习HCIA的小白1 天前
Apache Druid
apache