zoukankan      html  css  js  c++  java
  • 搭建 httpd 服务

    建立两个基于ip地址访问的网站,要求如下:
    1、该网站ip地址的主机位为100,设置DocumentRoot为/www/ip/100,网页内容为:this is 100。
    2、该网站ip地址主机位为200,设置DocumentRoot为/www/ip/200,网页内容为:this is 200。

    第一步

    装包
    yum install httpd -y # 装httpd的包
    查看防火墙状态

    systemctl status firewalld      # 查看防火墙的状态
    systemctl stop firewalld        # 用来关闭防火墙
    

    第二步

    配ip

    nmcli connection modify ens160 +ipv4.addresses 192.168.222.100/24 ipv4.gateway 192.168.222.1 ipv4.dns 192.168.222.1      # 主机位为 100 的
    nmcli connection modify ens160 +ipv4.addresses 192.168.222.200/24 ipv4.gateway 192.168.222.1 ipv4.dns 192.168.222.1      # 主机位为 200 的 
    nmcli connection up ens160      # 启用网卡
    

    第三步

    创建目录

    mkdir -p /www/ip/100      # 递归创建 100 的目录
    mkdir /www/ip/200         # 创建 200 的目录
    

    写内容

    echo this is 100 > /www/ip/100/index.html      # 给 100 写内容
    echo this is 200 > /www/ip/200/index.html      # 给 200 写内容
    

    第四步

    写配置文件

    vim /etc/httpd/conf.d/100.conf 
    <virtualhost 192.168.222.100:80>                                # 虚拟主机地址
            documentroot /www/ip/100                                # 文档根目录
            servername 192.168.222.100                              # 服务器名称
            errorlog "/var/log/httpd/100.error_log"                 # 错误日志存放路径 
            customlog "/var/log/httpd/100.access_log" common        # 访问日志存放路径
    </virtualhost>                                                  # 结束标记
    
    <directory /www/ip/100>                                         # 目录权限给予
            allowoverride none                            
            require all granted                        
    </directory>                                                    # 结束标记
    
    

    重启服务
    systemctl restart httpd # 重启 httpd 服务

  • 相关阅读:
    算法之我见
    meobius与DBTwin实现原理
    MongoDB应用学习
    重要通知
    lucenc代码阅读指南、测试范例
    什么是IoC以及理解为什么要使用Ioc
    策略模式实现支持多种类数据库的DBHelp
    为什么使用TFS 2012进行源代码管理——TFS 2012使用简介(一)
    我们到底能走多远系列
    Eclipse+Tomcat+MySQL+MyEclipse
  • 原文地址:https://www.cnblogs.com/li-qing/p/14002450.html
Copyright © 2011-2022 走看看