- 浏览: 849290 次
- 性别:
- 来自: lanzhou
文章分类
最新评论
-
liu346435400:
楼主讲了实话啊,中国程序员的现状,也是只见中国程序员拼死拼活的 ...
中国的程序员为什么这么辛苦 -
qw8226718:
国内ASP.NET下功能比较完善,优化比较好的Spacebui ...
国内外开源sns源码大全 -
dotjar:
敢问兰州的大哥,Prism 现在在12.04LTS上可用么?我 ...
最佳 Ubuntu 下 WebQQ 聊天体验 -
coralsea:
兄弟,卫星通信不是这么简单的,单向接收卫星广播信号不需要太大的 ...
Google 上网 -
txin0814:
我成功安装chrome frame后 在IE地址栏前加上cf: ...
IE中使用Google Chrome Frame运行HTML 5
Sun’s VirtualBox is ideal for testing different desktop environments (for example, browser testing), but I’ve discovered it’s also great for running a test server environment. Instead of setting up Apache, PHP, and MySQL right on your desktop machine, you can place them in a virtual Linux server. That way there’s no interference with your desktop, and you can ensure that your development environment is as close as possible to your eventual deployment environment.
With a virtual Linux server running inside your desktop operating system, you can SSH into it, upload files to it, load web pages from it–whatever you’d do with a real live server. And all the software you need is free and simple to configure. Let’s make a start!
Setting Up Shop
The first step is to download the VirtualBox client . Pick the version appropriate for your host system.
You’ll also want to grab a disk image for your Linux server. For this tutorial, I’ll be using the 64-bit version of Ubuntu server 9.04 , but feel free to use whatever distribution you’re more comfortable with. Of course, you might need to adapt some of the instructions to your particular setup.
We could also use a desktop build, but since we’re only interested in the server functionality, it’s best to stick with a server build: we’ll save on memory because no graphical desktop interface is loaded.
Installing the Ubuntu Server
Start up VirtualBox and click New for a new virtual machine. Step through the wizard, making sure to choose the 64-bit version of Ubuntu (if that’s the disk image you downloaded). I used the defaults for every other option: RAM, disk size, disk type, and so on.
Now select your new VM and click Start . VirtualBox will ask you how to install the OS on your virtual machine. Since we downloaded an .iso, choose CD/DVD-ROM device from the Media Type menu and Image File from the Media Source menu, selecting your Ubuntu Server iso. As the system boots, you’ll be presented with Ubuntu’s installer. Choose your language, and then select Install Ubuntu Server .
Follow the on-screen instructions to install the server. Notice that when you come to partitioning your hard disk, the virtual machine only “sees” the disk image you created before. Feel free to use the whole disk. Later on in the process, the installer will prompt you to install additional software. For our purposes, we’ll install the LAMP server and OpenSSH server packages. This way we have everything we need for a fully functional web server out of the box.
When it comes time to reboot your new server, you can “eject” the installation CD by choosing Devices>Unmount CD/DVD-ROM from the VirtualBox menu.
Log into your new system with the username and password you chose during installation. It’s also a good idea to upgrade your system with:
1 | sudo aptitude update |
2 | sudo aptitude safe-upgrade |
view plain | print |
sudo aptitude update
sudo aptitude safe-upgrade
Accessing the Virtual Server from the Host System
Now that our server is up and running, we want to be able to access it from our host system. We’ll set it up so we can SSH to it, transfer files to it via SFTP, and make HTTP requests to Apache.
To do all this we need to edit the xml configuration file for our virtual machine:
- On a Mac, the file is found at
~/Library/VirtualBox/Machines/<machine name>/<machine name>.xml
- On Windows, it’s inside the
.VirtualBox/Machines
subdirectory in your home folder.
So for my machine, which I’ve called “Ubuntu Server,” I’m editing Machines/Ubuntu Server/Ubuntu Server.xml
At the top of the file you should see an <ExtraData>
tag. Inside that tag, copy in the following tags:
1 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222"/> |
2 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/> |
3 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/> |
4 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888"/> |
5 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/> |
6 | <ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/> |
view plain | print |
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="2222"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8888"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/>
<ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/>
These lines configure VirtualBox to forward requests to specific ports on the host system onto other specified ports on the guest system. For SSH, we’re forwarding port 2222 of the host system to port 22 of the guest system (where OpenSSH is listening). The same principle applies to the Apache configuration items, with port 8888 on the host mapping to port 80 on the guest.
With that done, save the xml file and restart your virtual machine.
If the machine fails to start, it’s likely to be because of a
network interface configuration problem. In the lines we added, we
specified pcnet
as the network interface. To ensure
that’s what your virtual machine is using, right-click on it in the
main VirtualBox window and click Settings
. In the Network
tab, select one of the PCnet adapters from the Adapter Type
drop-down. You should be able to restart your virtual machine with no problems now.
Now if you open a browser on your host system and point it to http://localhost:8888/
you should see the default Apache “It works!” page. Great!
Similarly, to SSH into your new server, SSH to port 2222 on localhost with the username you set during the Ubuntu server installation. (If you’re on Windows, you can use the PuTTY SSH client to perform the same function):
1 | ssh -l <username> -p 2222 localhost |
view plain | print |
ssh -l <username> -p 2222 localhost
You’ll receive the usual “unknown host” security warning; type “yes” to connect and you’ll be prompted for your password. Upon entering it, you should be logged in to your server! Feel free to look around and make yourself at home.
While we’re still logged in, let’s do one more task: by default the Apache web root in Ubuntu Server is /var/www/
,
which your default user won’t have write permissions for. Let’s change
that, so you can upload files to your web root with SFTP. Enter this
command and hit return:
1 | sudo chown <username> /var/www |
view plain | print |
sudo chown <username> /var/www
To connect to your server with FTP, no extra configuration is
necessary. OpenSSH gives you “free” FTP via the SFTP (SSH FTP)
protocol. Most clients (FileZilla
,
for example) support it; just choose SFTP as the protocol, localhost as
the server with port 2222, and your Ubuntu username and password.
Choose /var/www/
as the default directory, and you should be able to transfer files to and from your server.
Let’s test that everything is working: create a php file named info.php
containing the usual phpinfo
call:
1 | <?php |
2 | phpinfo(); |
3 | ?> |
view plain | print |
<?php
phpinfo();
?>
Use your FTP client to upload that file to your server’s /var/www/
folder. Now point your browser to http://localhost:8888/info.php
, and you’ll see the PHP info page. The System
row at the top of the table will tell you PHP is running on Ubuntu.
There you have it! You can test server configurations, brush up on your sysadmin skills, and develop your web sites and applications in a full Linux server environment running inside your usual desktop.
发表评论
-
谷歌副总裁称三年后台式电脑与搜索无关
2010-03-05 08:27 976谷歌声称,大约三年的时间,台式电脑将会逐渐被移动设备所取代。越 ... -
李开复:Vista 系统失败的真正内幕
2010-03-05 07:14 1061曾参与Windows Vista研发的李开复,在近日发表的博文 ... -
Android也创富:开发者月入1.3万美元
2010-03-04 12:48 872据国外媒体报道,一位名叫爱德华·金姆(Edward Kim ... -
星际争霸2的图形界面几乎全部使用Flash搭建?
2010-02-25 09:11 842国外一名玩家在使用工具破解了星际争霸2Beta版的资源包后发现 ... -
电脑DIY市场正在走向末路
2010-02-09 10:49 963作为多年来的DIY爱好者,写出上面的标题着实让自己感到有些难过 ... -
VMWare下安装MAC OS X Snow Leopard 10.6
2010-02-07 08:52 10734这是转载自远景论坛ycjcn 的帖子,大家可以点这查看原 ... -
Chrome操作系统13大要点
2009-11-22 05:38 1102·Chrome OS用户无法下载安装 ·Chrome OS将 ... -
揭开神秘面纱!谷歌Chrome OS操作系统大揭秘
2009-11-22 05:37 1192北京时间11月20日凌晨消息,谷歌于美国西部时间11月19日 ... -
家庭教育的20条金科玉律
2009-11-16 11:32 910一: 家长在家庭教育时一定要记住情感教育永远都大于道理教育。 ... -
微软修补Windows操作系统核心漏洞
2009-11-14 10:33 968微软于周二(11/9)公布了6大更新,修补15个安全漏洞, ... -
Update on the Windows 7 USB/DVD Tool
2009-11-14 10:32 1110As you've likely read and as ... -
暖气不热的100个原因
2009-11-14 00:05 1898暖气不热的原因比较复杂,并不是由几个或十几个原因就可 ... -
Phoenix Award BIOS将停产
2009-11-13 11:31 1176Phoenix/Award BIOS的总公司 ... -
Beware the Fake Google Chrome OS Download
2009-10-31 20:55 1012Google recently announced that ... -
吓坏微软 传Chrome OS测试版网络偷跑
2009-10-31 20:50 1127Google Chrome OS相信不少人已经不会陌生 ... -
Google Wave Federation: Why it Matters
2009-10-31 15:21 866According to The Next Web , th ... -
Google投资“暗光纤” 带宽成本几乎为零
2009-10-29 15:52 1039据国外媒体报道,拥有Y ... -
不能忽视的虚拟化技术漏洞
2009-10-25 08:48 1188恶意软件从一台虚拟机 ... -
不看后悔的行货iPhone资费大PK(转载)
2009-10-25 08:45 765眼看着就要到月底,i ... -
外贸B2B:电子商务新引擎
2009-10-25 08:41 929外贸B2B:电子商务新引 ...
相关推荐
How to build compile server with virtualbox & samba
### 如何在VirtualBox中构建Ubuntu Linux主机 #### 引言 本文档旨在指导您如何在VirtualBox虚拟环境中搭建一个Ubuntu Linux系统。该过程已经成功应用于Ubuntu 8.04、9.10以及10.04版本,并且与VirtualBox 3.1.2及...
通过以上介绍可以看出,《Getting Started with Oracle VM VirtualBox》这本书不仅是一本很好的入门指南,还提供了深入的实践指导,对于希望了解并掌握 VirtualBox 使用方法的人来说是不可多得的好资源。无论是新手...
### Oracle 12c RAC 安装在 Linux 上使用 VirtualBox #### 一、概述 Oracle Real Application Clusters (RAC) 是一种允许多个 Oracle 数据库实例同时访问单个数据库的技术,以此来提高可用性和可扩展性。本文将详细...
在本文中,我们将深入探讨VirtualBox 6.1.26版本及其与Windows 10和Windows Server 2012 R2系统的集成。 首先,VirtualBox 6.1.26是该软件的一个稳定版本,提供了多项性能优化和错误修复。这包括改进的USB设备支持...
### Oracle 11g RAC 安装在 Linux 上使用 VirtualBox 的详细步骤与注意事项 #### 前言 Oracle Real Application Clusters (RAC) 是一种多节点集群数据库解决方案,能够提供高可用性和可扩展性。在本篇文档中,我们...
目前,VirtualBox运行在Windows、Linux、Macintosh和Solaris主机上,并支持大量的客户操作系统,包括但不限于Windows (NT 4.0, 2000, XP, Server 2003, Vista, Windows 7, Windows 8, Windows 10), DOS/Windows 3。...
VirtualBox
Support for USB 2.0 and USB 3.0 devices,...Please install the extension pack with the same version as your installed version of VirtualBox VirtualBox 扩展包 用usb设备时需要安装,请注意版本号,这是4.3.2的
### VirtualBox中安装Ubuntu 8.04 Server 在虚拟化技术越来越被广泛使用的今天,通过虚拟机软件如VirtualBox来模拟不同的操作系统环境已经成为一种非常常见的做法。本篇内容将详细介绍如何在VirtualBox中安装Ubuntu...
在VirtualBox主界面,点击“新建”按钮,按照提示输入虚拟机名称(如“Windows 2008 Server”),选择操作系统类型(Windows Server 2008),并指定内存大小(推荐至少1GB,但可根据实际需求调整)。然后创建虚拟...
因为他是开源的,不同于VM,而且功能强大,可以在 Linux/Mac 和 Windows 主机中运行,并 支持在其中安装 Windows (NT 4.0、2000、XP、Server 2003、Vista)、DOS/Windows 3.x、Linux (2.4 和 2.6)、OpenBSD 等系列的客户...
VirtualBox6.1.8 OSX mac版本,安装教程请参考: https://blog.csdn.net/qq_34160841/article/details/106225161
Genymotion-2.11.0+VirtualBox一体包, 文件总共2个包,官网下载最新版本,直接安装就可以使用模拟器,方便实用,两个一起下载后解压缩 ,总共两个包
With it, enterprises can cost-effectively deliver core business services, enable secure networks, and simplify the management of their heterogeneous IT infrastructure, maximizing efficiency and value...
VirtualBox 是一款开源虚拟机软件。VirtualBox 是由德国 Innotek 公司开发,由Sun Microsystems公司出品的软件,使用Qt编写,在 Sun 被 Oracle 收购后正式更名成 Oracle VM VirtualBox。Innotek 以 GNU General ...
《虚拟化技术与VirtualBox 4.2.4在H3C环境中的应用》 在IT领域,虚拟化技术已经成为数据中心、服务器管理以及个人开发环境中不可或缺的一部分。VirtualBox,作为一个开源且跨平台的虚拟化软件,深受广大用户喜爱。...
《虚拟化技术详解:以VirtualBox 5.2.26-128414-Win为例》 虚拟化技术是现代计算机科学中的一个重要领域,它允许在单个物理硬件系统上运行多个独立的虚拟环境,每个环境都可以运行不同的操作系统和应用程序。...
VirtualBox是一款广受欢迎的开源虚拟化软件,由德国Oracle公司开发和维护。它允许用户在一台物理计算机上创建和运行多个虚拟机,每个虚拟机可以独立运行不同的操作系统,如Windows、Linux、macOS等。这款软件是免费...
在探讨Oracle VM VirtualBox虚拟机突然消失的问题前,我们首先要明白虚拟机的工作原理以及如何在VirtualBox中管理虚拟机。Oracle VM VirtualBox是一种开源的虚拟化软件,能够在一个物理机器上创建和运行多个虚拟机,...