XAMPP学习之路: 第二章 模拟服务器环境
来源:互联网 发布:唐宁为什么不红 知乎 编辑:程序博客网 时间:2024/06/04 23:43
这章很简单,就是在局域网里面模拟一个服务器环境。
首先打开C:\Windows\System32\drivers\etc\hosts
内容如下:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
可以看到里面定义了locahost为127.0.0.1,它的意思就是给127.0.0.1起了一个别名localhost.
我们在下面使用同样的方法模拟一个域名 ,格式 为 “本机ip” “模拟域名”
我的本机ip为192.168.103.128,我想在本机模拟一个域名 “wodeyuming.com”就添加如下
192.168.103.128 wodeyuming.com
配置完毕点保存,在本机ping wodeyuming.com正常是可以ping通的。
然后到xampp的安装目录下面的一个文件中把我们的虚拟域名添加进去,这样apache就可以用这个域名建立一个最基本的服务器了。
我的xampp安装了在e盘,需要更改的文件为E:\xampp\apache\conf\extra\httpd-vhosts.conf,
打开并且添加
<VirtualHost 192.168.103.128:80>
ServerName wodeyuming.com
DocumentRoot "E:/xampp/htdocs/dummy-host2.example.com"
</VirtualHost>
VirtualHost 为本机ip加端口号80,ServerName就是自己刚才模拟的域名,DocumentRoot 是服务器的文件目录。保存配置重启apache服务,就可以在本机下面访问
www.wodeyuming.com了,显示的内容就是DocumentRoot下面的工程文件。
我们学习的时候通常没有条件去申请一个真正的域名,用这种方法可以模拟比较真实的环境,只是服务器只能部署在局域网段内。
- XAMPP学习之路: 第二章 模拟服务器环境
- php学习--xampp环境
- [XMPP]xampp服务器环境搭建
- XAMPP学习之路: 第一章 下载和安装XAMPP
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】SuSe11.1 上架设NFS服务器
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】SuSe11.1 上架设NFS服务器
- 我的服务器开发之路-windows安装xampp备注
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】FC6 上架设TFTP服务器,Transfer timed out
- 【嵌入式Linux学习七步曲之第二篇 交叉开发环境】FC6 上架设TFTP服务器,Transfer timed out
- Linux学习之路-03-Tomcat服务器环境搭建
- vtk学习之路—第二章
- laravel 学习之第二章
- Vue学习之第二章
- PHP 快速搭建生产环境之XAMPP版本历史
- Deeplearning学习之路_第二章(Vectorization&PCA)
- 数据结构学习之路-第二章:线性单链表
- 数据结构学习之路-第二章:静态单链表
- 数据结构学习之路-第二章:循环链表
- 【.Net码农】【MVC】.Net框架搭建之2、SQL Server MEF依赖注入 MVC Repository框架
- poj 2187 Beauty Contest 凸包 Graham
- ssl双向认证机制
- 接口测试
- ubuntu-E:Encountered a section with no Package: header的解决办法
- XAMPP学习之路: 第二章 模拟服务器环境
- EventBus的是使用
- nodejs远程连接redis
- crontab执行时间和系统时间不一致
- Hadoop伪分布式环境搭建
- java set集合总结
- hdu1263 二重map
- 基于localStorage的本地存储XSS
- 白帽子讲web安全之7(WEB 服务器配置安全)