modern php
This article was sponsored by modern.ie. Thank you for supporting the sponsors who make SitePoint possible!
本文由modern.ie赞助。 感谢您支持使SitePoint成为可能的赞助商!
Internet Explorer remains the world’s second most-used browser with almost one in four users on the desktop. A high proportion of those are from large businesses and government agencies yet, despite the commercial opportunities, few of us devote enough time to testing IE until it’s too late. The solution is to test early and test often — especially the older browsers.
Internet Explorer仍然是世界第二大使用率最高的浏览器, 桌面用户几乎占四分之一 。 其中很大一部分来自大型企业和政府机构,尽管有商业机会,但我们很少有人花足够的时间来测试IE,直到为时已晚。 解决方案是尽早测试并经常测试-特别是较旧的浏览器。
Testing IE poses a challenge; it’s available only on Windows and, even then, you can install only one version at a time. Emulators and IE’s own document modes can help but you should never trust them for anything more than basic layout checks.
测试IE带来了挑战。 它仅在Windows上可用,即使那样,您一次也只能安装一个版本。 模拟器和IE自己的文档模式可以提供帮助,但是除了基本的布局检查之外,您永远不要信任它们。
A few years ago it would have been necessary to install and maintain a suite of PCs with various combinations of Windows and IE. Fortunately, we can do the same without hardware using Virtual Machines.
几年前,有必要安装和维护一套具有Windows和IE各种组合的PC。 幸运的是,我们无需使用虚拟机即可在没有硬件的情况下完成相同的工作。
什么是虚拟机? (What are Virtual Machines?)
You’ve possibly seen emulators that run old operating systems such as Amiga OS, games consoles, or arcade machines on Windows, Mac, or Linux. In essence, these are Virtual Machines (VMs) that make the original OS and software think it’s running on real hardware. In reality, it’s all happening within the host PC’s memory.
您可能已经看到了运行旧操作系统(例如Amiga OS,游戏机或Windows,Mac或Linux上的街机)的模拟器。 从本质上讲,这些是使原始OS和软件认为其在真实硬件上运行的虚拟机(VM)。 实际上,这都是在主机PC的内存中发生的。
We’re not limited to old OSs — we can emulate a real PC and run any platform we desire. For example, we can run Windows XP in a VM application on Windows 8.1 so we can retain older, incompatible software. Because it’s handled as a data file, we can start, stop move or restore XP anytime we choose.
我们不仅限于旧的操作系统-我们可以模拟真实的PC并运行我们想要的任何平台。 例如,我们可以在Windows 8.1的VM应用程序中运行Windows XP,这样我们就可以保留较旧的不兼容软件。 由于它作为数据文件处理,因此我们可以随时选择启动,停止移动或还原XP。
Virtual Machines therefore provide a mechanism to run any edition of Internet Explorer from a Windows, Mac or Linux host. There’s little excuse — you probably have the software already and Microsoft provide a range of free Windows/IE VMs at modern.ie.
因此,虚拟机提供了一种从Windows,Mac或Linux主机运行任何版本的Internet Explorer的机制。 几乎没有任何借口-您可能已经拥有该软件,并且Microsoft在modern.ie上提供了一系列免费的Windows / IE VM。
虚拟机主机软件 (Virtual Machine Host Software)
The most popular VM hosts are:
最受欢迎的VM主机是:
VirtualBox (open source — Windows, Mac, Linux)
VirtualBox (开源-Windows,Mac,Linux)
VMware (commercial — Windows, Mac, Linux)
VMware (商业-Windows,Mac,Linux)
Hyper-V (free — add-on for Windows 8 and Server 2012)
Hyper-V (免费-Windows 8和Server 2012的附加组件)
Virtual PC (free — add-on for Windows 7)
虚拟PC (免费-Windows 7附加组件)
Parallels (commercial — Mac only)
Parallels (商用-仅限Mac)
For the purposes of this article, we’ll use VirtualBox running on a Mac. It’s available on all platforms, is easy to install, fast, and it’s free. Head over to virtualbox.org then download and install the application for your OS.
出于本文的目的,我们将使用在Mac上运行的VirtualBox。 它适用于所有平台,易于安装,快速且免费。 转到virtualbox.org,然后下载并安装适用于您的OS的应用程序。
The other VM hosts have similar processes — full instructions are available at modern.ie.
其他VM主机具有类似的流程-有关完整说明,请访问modern.ie 。
安装虚拟机 (Installing a Virtual Machine)
Visit modern.ie and follow the Test your site using free virtual machines link:
访问modern.ie并遵循“ 使用免费的虚拟机测试您的站点”链接:
Now select your host OS and virtual host platform — we’re using VirtualBox running on a Mac:
现在,选择您的主机操作系统和虚拟主机平台-我们正在使用在Mac上运行的VirtualBox:
Various Windows and IE VMs are presented. At the time of writing, the following combinations are available:
介绍了各种Windows和IE VM。 在撰写本文时,可以使用以下组合:
- Windows XP + IE6 Windows XP + IE6
- Windows Vista + IE7 Windows Vista + IE7
- Windows XP + IE8 Windows XP + IE8
- Windows 7 + IE8 Windows 7 + IE8
- Windows 7 + IE9 Windows 7 + IE9
- Windows 7 + IE10 Windows 7 + IE10
- Windows 8 + IE10 Windows 8 + IE10
- Windows 7 + IE11 Windows 7 + IE11
- Windows 8.1 + IE11 Windows 8.1 + IE11
These are fully-installed images of the whole operating system: the downloads are several gigabytes in size — be prepared for a long wait on slower connections.
这些是整个操作系统的完全安装的映像:下载文件大小为千兆字节-准备在较慢的连接上等待很长时间。
That said, you’re unlikely to require all the VMs. For the average site, IE6 and IE7 are dead. IE9 and 10 are normally well behaved and have mostly been superseded by IE11. I would therefore suggest IE8 on XP and IE11 on Windows 8.1 as a minimum but you should analyze your own site’s traffic to ensure you’re testing appropriate combinations.
也就是说,您不太可能需要所有VM。 对于普通站点,IE6和IE7已死。 IE9和10通常表现良好,并已被IE11取代。 因此,我建议至少使用XP上的IE8和Windows 8.1上的IE11,但是您应该分析自己网站的流量,以确保测试适当的组合。
Having chosen an image, download all the files. The Mac VirtualBox images have a number of RAR files and a single SFX file. Assuming you’ve downloaded to your “Downloads” folder, open a command terminal and enter:
选择图像后,下载所有文件。 Mac VirtualBox映像具有多个RAR文件和一个SFX文件。 假设您已下载到“下载”文件夹,请打开命令终端并输入:
cd ~Downloads
chmod +x filename.sfx
./filename.sfx
where filename.sfx is the full name of the .SFX file. This will expand your files into a single OVA file.
其中filename.sfx是.SFX文件的全名。 这会将您的文件扩展为单个OVA文件。
Next, start VirtualBox and choose Virtual Machines > Import from the main menu:
接下来,启动VirtualBox并从主菜单中选择“ 虚拟机”>“导入 ”:
Select the OVA file, click Continue and import the VM. It will shortly appear in the list in the left-hand pane. Click once to select it, then hit Start to launch the Virtual Machine. After a few seconds, you’ll be booted into Windows and can run Internet Explorer:
选择OVA文件,单击“ 继续”并导入VM。 它将很快出现在左侧窗格的列表中。 单击一次以选择它,然后单击“ 启动”以启动虚拟机。 几秒钟后,您将启动Windows并可以运行Internet Explorer:
VirtualBox provides a special IP address at http://10.0.2.2/ which loops back to the host’s IP address so you can test pages on your local server. The VM is also added to your network so you can enter your host PC’s IP address as an alternative. However, remember that http://localhost/
and http://127.0.0.1/
are the local addresses of the new VM — they cannot be used for testing unless you update the VM’s host file.
VirtualBox在http://10.0.2.2/提供了一个特殊的IP地址,该地址循环返回到主机的IP地址,因此您可以在本地服务器上测试页面。 VM也已添加到您的网络,因此您可以输入主机PC的IP地址作为替代。 但是,请记住, http://localhost/
和http://127.0.0.1/
是新VM的本地地址—除非您更新VM的主机文件,否则它们不能用于测试。
Windows许可限制 (Windows Licensing Restrictions)
All modern.ie VMs are full editions of Windows — you can install and use any software you like including other browsers.
所有modern.ie VM都是Windows的完整版-您可以安装和使用任何喜欢的软件,包括其他浏览器。
To prevent anyone using these images to run unlicensed copies of Windows indefinitely, they expire after 30 days (unless you enter an activation key). At that point, the OS will randomly reboot and become mostly unusable. You can, however, retain a copy of the downloaded files (or the VirtualBox OVA) and import the VM again.
为防止任何人使用这些映像无限期运行Windows的未经许可的副本,它们将在30天后过期(除非您输入激活密钥)。 届时,操作系统将随机重启并变得几乎无法使用。 但是,您可以保留下载文件的副本(或VirtualBox OVA),然后再次导入VM。
Fortunately, there is a way to extend Windows expiration. When you start receiving activation messages, run a command prompt as an administrator inside the VM. This is achieved by right-clicking the shortcut and choosing Run as administrator.
幸运的是, 有一种方法可以延长Windows的到期时间 。 当您开始接收激活消息时,请以管理员身份在VM内运行命令提示符。 这可以通过右键单击快捷方式并选择以管理员身份运行来实现 。
Then, for XP VMs, enter:
然后,对于XP VM,输入:
rundll32.exe syssetup,SetupOobeBnk
or, for Windows Vista, 7 or 8.1 enter:
或(对于Windows Vista,为7或8.1)输入:
slmgr /rearm
This can be done twice so, in effect, your license is extended to 90 days.
可以执行两次,这样实际上可以将您的许可证延长到90天。
Virtual Machines are the best way to test your site on IE and other Windows browsers. Modern.ie makes the process much easier and free. What are you waiting for?
虚拟机是在IE和其他Windows浏览器上测试站点的最佳方法。 Modern.ie使该过程更加轻松和免费。 你在等什么?
翻译自: https://www.sitepoint.com/virtual-machine-browser-testing-modern-ie/
modern php