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

  • 相关阅读:
    odoo国际化翻译
    Odoo创建基础模块和相关内容
    odoo权限管理(二.记录管理)
    推荐的 MongoDB 安装文档
    Python Spider 抓取今日头条街拍美图
    Python Spider 抓取猫眼电影TOP100
    如何选择 SQL Server 数据库跟操作系统版本
    Mongodb 折腾笔记
    MySQLReport
    kernel TCP time wait bucket table overflow
  • 原文地址:https://www.cnblogs.com/li-qing/p/14002450.html
Copyright © 2011-2022 走看看