一、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. cordova屏幕尺寸

    <platform name="android"> <!-- ldpi : 36x36 px mdpi : 48x48 px hdpi : 72x72 px xh ...

  2. float后怎么居中

    我们在用css float的时候,如何让文本水平居中真的很麻烦, [float]使div(或者其他标签)的宽度自适应其内容,但它却有个弊端:无法居中.[display:inline-block]也有同 ...

  3. c++之默认参数的函数

    默认参数,看个例子就明白了 int add(int a=5,int b=6,z=3): int main(){ add():// 全部默认 add(1,5)://第三个参数默认 add(1,2,3): ...

  4. 【leetcode刷题笔记】Reverse Nodes in k-Group

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If ...

  5. GVM管理Go版本

    1.为什么要安装GVM 1.1什么是GVM GVM是一个golang虚拟环境配置工具,其允许一台机器上安装多个golang版本,gvm是第三方开发的Go多版本管理工具,类似ruby里面的rvm工具.使 ...

  6. linux学习-环境变量与文件查找

  7. jquery 实现智能炫酷的翻页相册效果

    jquery 实现智能炫酷的翻页相册效果巧妙的运用 Html 的文档属性,大大减少jquery 的代码量,实现了智能炫酷的翻页相册.兼容性很好,实现了代码与标签的完全分离​1. [代码]jquery ...

  8. Delphi中TList类应用

    在DELPHI中指针最常见的就是和类TLIST结合起来使用.下面是一个很简单的例子,希望对这个例子的分析能让大家对使用TLIST类有一个简单的认识. 代码的功能是使用指针和Tlist来生成一个牌串,并 ...

  9. 学习c++的优秀博客(转)

    http://zhedahht.blog.163.com/  本博客讨论程序员面试题,并主要集中在C/C++.数据结构算法和算法上.http://saturnman.blog.163.com/ sat ...

  10. js和jquery 两种写法 鼠标经过图片切换背景效果

    这个是javascript的写法 <img src="res/img/shop-c_32.jpg" alt="" onmouseover="th ...