• linux 学习第十四天(Apache安装、基于ip、基于域名、基于端口配置)


    一、虚拟主机

    A、基于IP地址  B、基于域名  C、基于端口号

    复习yum仓库挂载

    mkdir /media/cdrom

    mount /dev/cdrom /media/cdrom/

    vim /etc/fstab

    /dev/cdrom /media/cdrom iso9960 defaults 0 0

    vim /etc/yum.repos.d/rhel7.repo

    yum install httpd

    systemctl restart httpd

    systemctl enable httpd

    vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

    systemctl restart network

    基于IP地址

     

    mkdir -p /home/wwwroot/10

    mkdir -p /home/wwwroot/20

    mkdir -p /home/wwwroot/30

    echo "1111111" > /home/wwwroot/10/index.html

    echo "2222222" > /home/wwwroot/20/index.html

    echo "3333333" > /home/wwwroot/30/index.html

    vim /etc/httpd/conf/httpd.conf

     

    systemctl restart httpd

    ls -lZd /var/www/html/

    semanage fcontext -at httpd_sys_content_t /home/wwwroot

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/10

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/20

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/30

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/10/*

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/20/*

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/30/*

    restorecon -Rv /home/wwwroot/

    基于域名

    mkdir -p /home/wwwroot/www

    mkdir -p /home/wwwroot/bbc

    mkdir -p /home/wwwroot/tech

    echo "wwwwwwwww" > www/index.html

    echo "bsbbbbbsbs" > bbs/index.html

    echo "techtechtech" > tech/index.html

    vim /etc/hosts

    ls -lZd /var/www/html  (查看默认网站下权限)

    添加基于域名虚拟主机权限

    semanage fcontext -at httpd_sys_content_t /home/wwwroot

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/www

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/www/*

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbc

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/bbc/*

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/tech/*

    restorecon -Rv /home/wwwroot/  (使配置生效)

     

    基于端口号

    mkdir -p /home/wwwroot/8555

    mkdir -p /home/wwwroot/8666

    echo "8555555555555" > /home/wwwroot/8555/index.html

    echo "8666666666666" > /home/wwwroot/8666/index.html

     

    semanage port -l | grep http  (查看关于httpd服务相关端口号)

    semanage port -at http_port_t -p tcp 8555

    semanage port -at http_port_t -p tcp 8666

    systemctl restart httpd

    systemctl enable httpd

    ls -lZd /var/www/html

    semanage fcontext -at httpd_sys_content_t /home/wwwroot

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/8555

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/8555/*

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/8666

    semanage fcontext -at httpd_sys_content_t /home/wwwroot/8666/*

    restorecon -Rv /home/wwwroot/

    Apache访问控制

    yum install httpd

    systemctl restart httpd

    systemctl enable httpd

    iptables -F

    service iptables save

    echo "weclcom to rise-house" > /var/www/html/server/index.html

    systemctl restart httpd

  • 相关阅读:
    一提黄金肯定就是西方的货币史
    封装QtCore(在非Qt项目里使用QString,QJson,QFileInfo,QFile等类)
    Qt 自定义事件(三种方法:继承QEvent,然后Send Post就都可以了,也可以覆盖customEvent函数,也可覆盖event()函数)
    MAC 设置环境变量path的几种方法
    深入Qt 学习 -- 反射机制(比较简单清楚)
    排序
    寄存器,cache、伙伴系统、内存碎片、段式页式存储管理
    NET Core项目
    消息队列
    RedisHelper
  • 原文地址:https://www.cnblogs.com/rise-home/p/10588722.html
Copyright © 2020-2023  润新知