一、http单域名访问

  1、安装软件: yum -y install httpd

  2、启动服务:systemctl  start httpd

  3、设置开机启动: systemctl enable httpd

  4、创建index.html : touch  /var/www/html/index.html

  5、在index.html里添加内容test : echo "test" >/var/www/html/index.html

  6、将 http 服务添加到防火墙: firewall-cmd  --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 service name=http accept'

  7、重新加载防火墙: firewall-cmd --reload

  8、创建httpd-vhosts.conf: vim /etc/httpd/conf.d/httpd-vhosts.conf

  9、在httpd-vhosts.conf添加如下内容:

    <VirtualHost *:80>

      DocumentRoot  /var/www/html

      ServerName  www.test.com

      ServerAlias  test.com

    </VirtualHost>

  10、重启http服务:systemctl restart httpd

  11、在/etc/hosts里添加如下内容:

    10.0.0.20  www.test.com

    10.0.0.20  test.com

  12、完成以上步骤上即可实现域名访问,linux域名访问命令: curl  www.test.com

二、多域名访问

  1、建立新目录: mkdir  /var/www/private

  2、创建index.html文件并添加内容 orange: echo "orange"  >/var/www/private/index.html

  3、在httpd-vhosts.conf里添加如下内容:

    <VirtualHost *:80>

      DocumentRoot  /var/www/private

      ServerName  www.private.com

      ServerAlias  private.com

    </VirtualHost>

  4、重启httpd服务: systemctl  restart httpd

  5、在/etc/hosts里添加如下内容:

    10.0.0.20 www.private.com

    10.0.0.20 private.com

三、只允许指定IP访问,在httpd-vhosts.conf里添加如下内容:

  <Directory /var/www/private>

    require  ip 10.0.0.21      // “require  local  allow” 表示只允许本机访问,“require ip 10.0.0.0/24” 则表示允许0段网络访问

    require all  denied       // 此项为默认设置,有无均可

  </Directory>

PS : 如局域网内没做DNS,则需要添加http服务器里的hosts文件里的相同内容到访问电脑的hosts文件里

CentOS 7 配置 http 服务器的更多相关文章

  1. centos下配置gitosis服务器遇到的困难

    这篇博客主要讲的是在centos下配置gitosis遇到的问题. 背景:centos7.2 64 :gitosis2.0 1.困难1 1)产生的问题及原因.gitosis没有安装成功,没有出现fini ...

  2. centos下配置gitosis服务器

    背景: 一台windows电脑,Xshell可以登录centos服务器(centos7.2 64位,有root用户权限),windows电脑已经安装好git和tortoies 在windows下下载和 ...

  3. Linux -- Centos 下配置LNAMP 服务器环境

    1.Mysql centos 7 下mysql被替换掉,如有需要请看另一篇: centos 6.5下: yum install mysql mysql-server mysql-devel 启动mys ...

  4. CentOS安装配置Git服务器(gitosis)

    主要参考: http://blog.csdn.net/dengjianqiang2011/article/details/9260435 辅助参考: http://freeloda.blog.51ct ...

  5. CentOS笔记——配置DNS服务器

    前话 咳咳,这次Linux系统的DNS服务器搭建我不得不记下来.,这错误真的太蛋疼了,我整整弄了两天才解决问题(抱歉我很蠢). 也许有人会和我犯同样的错误,给大家分享一下经验. 首先总结一下知识点: ...

  6. Linux(Centos)安装配置SVN服务器

    1. 安装SVN服务器: 检查是否已安装 # rpm -qa subversion 安装SVN服务器 # yum install httpd httpd-devel subversion mod_da ...

  7. CentOS 7 配置 ISCSI 服务器

    一.服务器配置 1.安装配置软件: yum install targetcli -y 2.进入配置界面: targetcli ,并进行如下配置: 1) /backstores/block create ...

  8. CentOS安装配置VSFTP服务器

    {:toc} 前言 本文用最简单的方式创建FTP服务,即创建一个大家都可以访问的目录,没有涉及到各种权限限制. 创建目录 在安装配置ftp之前,首先创建一个目录,用来做ftp根目录.我创建的是/hom ...

  9. CentOS安装配置radius服务器

    1.安装 Yum install -y freeradius freeradius-mysql freeradius-utils 2.配置 1)修改 clients.conf # vi /usr/lo ...

随机推荐

  1. static_class

    <?php class MyObject { public static $myStaticVar = 0; function myMethod() { self::$myStaticVar + ...

  2. jquery 如何获取单选框的值

    jquery 如何获取单选框的值   获取单选框的值有三种方式: 1.$('input:radio:checked').val():2.$("input[type='radio']:chec ...

  3. 每天一个Linux命令(26)chown命令

          chown命令改变某个文件或目录的所有者和所属的组,该命令可以向某个用户授权,使该用户变成指定文件的所有者或者改变文件所属的组.     (1)用法:     用法:  chown [选项 ...

  4. Data Structure Array: Maximum circular subarray sum

    http://www.geeksforgeeks.org/maximum-contiguous-circular-sum/ #include <iostream> #include < ...

  5. 有关java是编译型语言还是解释性语言

    博客分类: 技术杂谈 JavaD语言JVMC++C# 小生现在大二, java学习的时间不到一年 但是自认学习效率还是比较高的,同时在java上用时也比较多 在周末,放假,暑假. 每天能花费12+个小 ...

  6. 算法(Algorithms)第4版 练习 2.2.23

    测试结果: 算法(Algorithms)第4版 练习 2.2.10 算法(Algorithms)第4版 练习 2.2.11(1) 算法(Algorithms)第4版 练习 2.2.11(2) 算法(A ...

  7. php一维数组的创建

    php一维数组的创建 (1)通过array函数声明数组 使用array 函数定义数组,该函数返回通过所接受接收的参数建立的数组.array 函数使用的格式如下. $arry_name = array( ...

  8. linux开机过程

    一.MBR(main boot record)主引导记录 主引导记录位于0盘面,0磁道,0扇区,早期由512个字节组成. 其中446个字节是boot loader程序.Boot Loader是在操作系 ...

  9. MySQL 当记录不存在时insert,当记录存在时update

    MySQL当记录不存在时insert,当记录存在时更新:网上基本有三种解决方法 第一种: 示例一:insert多条记录 假设有一个主键为 client_id 的 clients 表,可以使用下面的语句 ...

  10. linux vsftpd 服务配置

    vsftpd.conf配置如下: # Example config file /etc/vsftpd/vsftpd.conf # # The default compiled in settings ...