《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
相关推荐
Fantasy丶夜雨笙歌16 小时前
Apache HTTP Server 从安装到配置
网络协议·http·apache
蠢货爱好者18 小时前
一分钟快速了解Apache
apache
麟城Lincoln18 小时前
【Linux-云原生-笔记】Apache相关
linux·笔记·云原生·apache·webserver
ZZZKKKRTSAE19 小时前
玩转rhel9 Apache
linux·运维·服务器·apache·web
HashData酷克数据1 天前
Apache Cloudberry 向量化实践(二):如何识别和定位向量化系统的性能瓶颈?
apache
HashData酷克数据2 天前
流批一体的“奥卡姆剃刀”:Apache Cloudberry 增量物化视图应用解析
apache
lang201509282 天前
什么是Apache Ignite的affinity(亲和性)
apache
Apache IoTDB3 天前
Apache IoTDB V2.0.4 发布|新增用户自定义表函数及多种内置表函数功能
apache·iotdb
TracyCoder1233 天前
Apache Shiro 框架详解
安全·apache·shiro·认证·登录