《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
相关推荐
小小龙学IT2 天前
Apache Airflow 2.x 深度指南:用 Python 编排一切的现代化工作流引擎
开发语言·python·apache
Shepherd06192 天前
【IT 运维】Apache 使用 mod_remoteip 恢复 Cloudflare 后的真实访客 IP
运维·tcp/ip·apache
isyangli_blog2 天前
SDN 基本应用实践 —— 使用命令行实现简易防火墙功能实验报告
服务器·php·apache
小小龙学IT3 天前
Apache Pulsar 深度解析:从架构设计到生产落地
apache
Full Stack Developme4 天前
Apache Tika 教程
java·开发语言·python·apache
laplaya4 天前
C++大型项目组件通信与依赖管理实践
c++·log4j·apache
万岳科技5 天前
教育培训小程序如何构建线上线下一体化教学体系
小程序·apache
yyuuuzz5 天前
云服务器软件部署的几个常见问题
运维·服务器·开发语言·网络·云计算·php·apache
分布式存储与RustFS5 天前
Apache Iceberg数据湖轻量化搭建:基于Rust开源存储方案
开源·apache·iceberg·rustfs·ai存储·ai memory·s3 table
睡不醒男孩0308235 天前
中启乘数 CLup 6.x Apache Doris 存算一体集群管理技术文档
apache·doris·clup