美文网首页
第十三周作业

第十三周作业

作者: 念念OPS | 来源:发表于2021-02-20 14:49 被阅读0次

1.使用ansible的playbook实现自动化安装httpd

太长了 单独写了个文章放在我ansible的文集里面了
使用ansible的playbook实现自动化安装httpd

2.建立httpd服务器,要求提供两个基于名称的虚拟主机
(1)www.X.com,页面文件目录为/web/vhosts/x;错误日志为
/var/log/httpd/x.err,访问日志为/var/log/httpd/x.access
(2)www.Y.com,页面文件目录为/web/vhosts/y;错误日志为 /var/log/httpd/www2.err,访问日志为/var/log/httpd/y.access
(3)为两个虚拟主机建立各自的主页文件index.html,内容分别为其对应的主机名

#建立documentroot目录即站点页面存放目录
mkdir -p /data/web{1..3} 
#准备站点日志
#准备站点页面
echo this is web1 > /data/web1/index.html
echo this is web2 > /data/web2/index.html
echo this is web3 > /data/web3/index.html

#编辑httpd的主配置文件httpd.conf
ServerRoot "httpd的软件目录"
includeoptional conf.d/*.conf #includeoptional 即使*.conf文件不存在也不会报错

#主配置文件定义了日志的格式
<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %{%F %T}t \"%r\" %>s %b %{User-agent}i" 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" common
</IfModule>
ErrorLog "logs/error_log"
LogLevel warn

#编辑虚拟主机配置文件
<virtualhost *:80>
    servername web1.wangcloud.top
    documentroot "/data/web1"
    <directory "/data/web1">
    require all granted
    Options None
    AllowOverride None
    </directory>
    ErrorLog "logs/web1_error.log"
    CustomLog "logs/web1_access.log" common
</virtualhost>

<virtualhost *:80>
    servername web2.wangcloud.top
    documentroot "/data/web2"
    <directory "/data/web2">
    require all granted
    Options None
    AllowOverride None
    </directory>
    ErrorLog "logs/web2_error.log"
    CustomLog "logs/web2_access.log" common
</virtualhost>

<virtualhost *:80>
    servername web3.wangcloud.top
    documentroot "/data/web3"
    <directory "/data/web3">
    require all granted
    Options None
    AllowOverride None
    </directory>
    ErrorLog "logs/web3_error.log"
    CustomLog "logs/web3_access.log" common
</virtualhost>

#编辑主机/etc/hosts文件 模拟DNS解析
#多虚拟主机技术一个IP相同端口根据FQDN不同区分站点访问
vim /etc/hosts
10.0.0.7 web1.wangcloud.top web2.wangcloud.top web3.wangcloud.top
#检测httpd配置文件语法
httpd -t
#重启httpd服务
systemctl restart httpd
#测试访问
root@7  conf.d]# curl web1.wangcloud.top
this is web1
root@7  conf.d]# curl web2.wangcloud.top
this is web2
root@7  conf.d]# curl web3.wangcloud.top
this is web3

相关文章

  • 2014301020155

    第九周作业:第九周作业 第十周作业:第十周作业 第十一周作业:第十一周作业 第十三周作业:第十三周作业 第十四周作...

  • 廖科才201430102104

    第八周作业 第二次作业 第三次作业 第四次作业,第十二周作业 第五次作业,第十三周作业 第六次作业,第十四周作业 ...

  • vsftpd 、iptables

    (第十三周作业) 1、搭建vsftpd,并实现虚拟用户root用户登录#yum install vsftpd -y...

  • 第十三周作业

  • 第十三周作业

    1、搭建时间服务器,日志服务器并简述sudo安全切换。 1)搭建时间服务器: 早期是用ntp服务: #yum in...

  • 第十三周作业

    1.使用ansible的playbook实现自动化安装httpd 太长了 单独写了个文章放在我ansible的文集...

  • 实践-python实现回归分析

    作业:本周是统计学学习小组-第二期的第十三周,我们这周是python实践周,实现的内容是第十二周的回归分析部分,大...

  • 2018-04-05

    香帅金融课第十三周

  • 乐朴童学明珠班第十三周周总

    20181207乐朴明珠班第十三周周总各位家长好这周是教学的第十三周,之前12周的月总叙述孩子们每周做什么了比较多...

  • 第13周总结第14周计划

    第十三周总结 1、按要求晨诵 完成 2、每天按要求完成英语读写作业 完成 3、每天坚持读书至少30分钟 完成 4...

网友评论

      本文标题:第十三周作业

      本文链接:https://www.haomeiwen.com/subject/piatfltx.html