RHCE第四次(项目)

使用Shell脚本实现以下需求:
1、创建本地软件仓库
2、安装httpd和bind软件
3、按如下要求生成web配置文件
        1、   documentroot  /www
        2、   listen  8080
        3、   welcome  index.html
4、访问地址为   www.exam.com:8080  
5、放行防火墙规则和定义selinux上下文,使web服务可以正常使用
6、定义dns服务可以正常解析所有需要的主机名
7、所有都ok,echo  "all ok"

#!/bin/bash

# 1. 创建本地软件仓库

# 2. 安装httpd和bind软件

yum install -y httpd bind

# 3. 生成web配置文件

cat > /etc/httpd/conf/httpd.conf <<EOL

ServerRoot "/etc/httpd"

Listen 8080

Include conf.modules.d/*.conf

User apache

Group apache

<Directory />

    AllowOverride none

    Require all denied

</Directory>

DocumentRoot "/www"

<Directory "/www">

    Options Indexes FollowSymLinks

    AllowOverride None

    Require all granted

</Directory>

<IfModule dir_module>

    DirectoryIndex index.html

</IfModule>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>

      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio

    </IfModule>

    CustomLog "logs/access_log" combined

</IfModule>

<IfModule mime_module>

    TypesConfig /etc/mime.types

    AddType application/x-compress .Z

    AddType application/x-gzip .gz .tgz

</IfModule>

<IfModule ssl_module>

SSLRandomSeed startup builtin

SSLRandomSeed connect builtin

</IfModule>

EOL

# 4. 访问地址为 www.exam.com:8080

echo "127.0.0.1 www.exam.com" >> /etc/hosts

# 5. 放行防火墙规则和定义selinux上下文,使web服务可以正常使用

firewall-cmd --permanent --add-port=8080/tcp

firewall-cmd --reload

setsebool -P httpd_can_network_connect 1

# 6. 定义dns服务可以正常解析所有需要的主机名

cat > /etc/named.conf <<EOL

options {

    directory "/var/named";

};

zone "exam.com" IN {

    type master;

    file "exam.com.zone";

};

EOL

cat > /var/named/exam.com.zone <<EOL

\$TTL 86400

@       IN SOA  exam.com. root.exam.com. (

                        2023100101      ; Serial

                        3600            ; Refresh

                        1800            ; Retry

                        604800          ; Expire

                        86400           ; Minimum TTL

)

@       IN NS   ns.exam.com.

ns      IN A    127.0.0.1

www     IN A    127.0.0.1

EOL

# 7. 所有都ok,echo "all ok"

echo "all ok"

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值