《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
相关推荐
Fireworkitte6 小时前
Apache POI 详解 - Java 操作 Excel/Word/PPT
java·apache·excel
蚂蚁数据AntData11 小时前
从性能优化赛到社区Committer,走进赵宇捷在Apache Fory的成长之路
大数据·开源·apache·数据库架构
小湘西11 小时前
Apache HttpClient 的请求模型和 I/O 类型
java·http·apache
超级小忍11 天前
Spring Boot 集成 Apache Kafka 实战指南
spring boot·kafka·apache
天上掉下来个程小白13 天前
Apache ECharts-02.入门案例
前端·spring boot·apache·echarts·苍穹外卖
SelectDB技术团队13 天前
Apache Doris 3.0.6 版本正式发布
大数据·数据分析·apache·实时分析·极速分析
guygg8814 天前
Linux中的阻塞信号与信号原理
linux·mysql·apache
天上掉下来个程小白15 天前
Apache ECharts-01.介绍
前端·javascript·spring boot·apache·苍穹外卖
gb421528715 天前
高性能场景使用Protocol Buffers/Apache Avro进行序列化怎么实现呢
apache