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 服务

  • 相关阅读:
    太原市圆通快递网点
    快递单号查询小工具
    C#快递单号查询源码
    爱快递快递接口使用说明
    如何把网站及数据库部署到Windows Azure
    从window.console&&console.log(123)浅谈JS的且运算逻辑(&&)
    C# Enum 简易权限设计 使用FlagsAttribute属性
    Lambda 表达式(C# 编程指南)
    C# list使用方法
    SharePoint Server 2013介绍v2
  • 原文地址:https://www.cnblogs.com/li-qing/p/14002450.html
Copyright © 2011-2022 走看看