在win10中使用VirtualBox安装Ubuntu Server 16.04.5

一:安装前备份

  • 浏览器收藏夹
  • 千牛聊天记录
  • 微信聊天记录
  • 将C盘的有用的东西备份下

二:全新安装win10

  • 从移动硬盘还原系统,先第一项,后面的会蓝屏,耗时30分钟
  • 设置网络,静态ip,保证能正常上网,Ctrl+R后输入ncpa.cpl,有下面三种连接网络的方式
  • WLAN(Wireless Local Area Networks)无线局域网络,使用设备Intel(R) Dual Band Wireless-AC 3165
  • 蓝牙网络连接,Bluetooth Device (Personal Area Network)
  • 以太网,Realtek PCIe GBE Family Controller
01. 360杀毒
02. 360安全卫士
03. 360压缩软件
04. 搜狗五笔输入法
05. chrome浏览器
06. sublime
07. Adobe系列,先安装,ps要先到
08. 微信 修改本地数据储存路径为E:/data2018
09. qq 修改本地数据储存路径为E:/data2018
10. 360驱动大师升级驱动,看能否解决蓝牙名字乱码问题,升级驱动,乱码解决
11. 迅雷
12. githubdesktop git版本控制,太慢,未解决方法
13. git代码管理 git版本控制
14. phpstorm2017.1.2
15. winscp

三:安装虚拟机VirtualBox

04. 下载 windows hosts,版本:5.2.18,112M
  • 安装后,在设置管理器中会出现一块仅主机(Host-only)适配器 ,同时在网络连接里出出仅主机网络,如下图

图片描述

  • 看下配置文件

图片描述

<?xml version="1.0"?>
<!--
** 不要编辑这个文件,即使改后,也会被覆盖,请使用VBoxManage或VirtualBox Manager GUI 来修改虚拟机的配置
-->
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.12-windows">
  <Global>
    <ExtraData>
      <ExtraDataItem name="GUI/HostNetworkManager/Details/Expanded" value="true"/>
      <ExtraDataItem name="GUI/LastWindowPosition" value="477,239,1165,522"/>
      <ExtraDataItem name="GUI/SplitterSizes" value="386,773"/>
      <ExtraDataItem name="GUI/Toolbar/GlobalTools/Order" value="HostNetwork"/>
      <ExtraDataItem name="GUI/Toolbar/MachineTools/Order" value="None"/>
      <ExtraDataItem name="GUI/UpdateCheckCount" value="2"/>
      <ExtraDataItem name="GUI/UpdateDate" value="1 d, 2018-09-18, stable, 5.2.18"/>
    </ExtraData>
    <MachineRegistry/>
    <NetserviceRegistry>
      <DHCPServers>
        <DHCPServer networkName="HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter" IPAddress="192.168.56.100" networkMask="255.255.255.0" lowerIP="192.168.56.101" upperIP="192.168.56.254" enabled="1"/>
      </DHCPServers>
    </NetserviceRegistry>
    <SystemProperties defaultMachineFolder="C:\Users\Administrator\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
    <USBDeviceFilters/>
  </Global>
</VirtualBox>

VirtualBox使用说明

"E:\Program Files\Oracle\VirtualBox\VirtualBox.chm",有问题可以查阅这里的使用教程

熟悉VBoxManage.exe等工具

熟悉网络配置

虚拟机可以设4个网卡,第1个网卡为NAT,是默认装的,不修改,增加第2个网卡,类型为桥接并接入网线,选择界面名称为: Realtek PCIe GBE Family Controller,也就是它走的是实际物理网卡,将它的ip地址设为同宿主机的ip同一个段,宿主机是192.168.0.10

四:安装Ubuntu16

05. 下载,版本16.04.5

新建虚拟电脑

  1. 新建虚拟脑

    • 名称:ubuntu16-20180917
    • 类型Linux
    • Ubuntu(64-bit)
  2. 内存大小

    • 1024MB
  3. 虚拟硬盘

    • 现在创建虚拟硬盘
  4. 虚拟硬盘文件类型

    • VMDK
  5. 存储在物理硬盘上

    • 动态分配
  6. 文件位置和大小

    • E:\data2018\ubuntu16-20180917.vmdk
      E:\data2018\ubuntu16-20180917.vmdk文件目前大小是1344KB
      C:\Users\Administrator\VirtualBox VMs\ubuntu16-20180917\ubuntu16-20180917.vboxubuntu16-20180917.vbox-prev两个文件
    • 10.00GB
 // C:\Users\Administrator\VirtualBox VMs\ubuntu16-20180917\ubuntu16-20180917.vbox内容
  <?xml version="1.0"?>
<!--
** 不要修改这个文件,如果要修改请用VBoxManage或 VirtualBox Manager GUI
-->
<VirtualBox xmlns="http://www.virtualbox.org/" version="1.16-windows">
  <Machine uuid="{ff7a8119-0c7f-4657-8934-2721e066dd96}" name="ubuntu16-20180917" OSType="Ubuntu_64" snapshotFolder="Snapshots" lastStateChange="2018-09-17T05:37:06Z">
    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{86707f79-b0ca-4eb4-8e5e-330992e27cbf}" location="E:/data2018/ubuntu16-20180917.vmdk" format="VMDK" type="Normal"/>
      </HardDisks>
    </MediaRegistry>
    <ExtraData>
      <ExtraDataItem name="GUI/FirstRun" value="yes"/>
    </ExtraData>
    <Hardware>
      <CPU>
        <PAE enabled="false"/>
        <LongMode enabled="true"/>
        <X2APIC enabled="true"/>
        <HardwareVirtExLargePages enabled="true"/>
      </CPU>
      <Memory RAMSize="1024"/>
      <HID Pointing="USBTablet"/>
      <Display VRAMSize="16"/>
      <BIOS>
        <IOAPIC enabled="true"/>
      </BIOS>
      <USB>
        <Controllers>
          <Controller name="OHCI" type="OHCI"/>
        </Controllers>
      </USB>
      <Network>
        <Adapter slot="0" enabled="true" MACAddress="080027BF4F99" type="82540EM">
          <NAT/>
        </Adapter>
      </Network>
      <AudioAdapter codec="AD1980" driver="DirectSound" enabled="true" enabledIn="false"/>
      <RTC localOrUTC="UTC"/>
    </Hardware>
    <StorageControllers>
      <StorageController name="IDE" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
        <AttachedDevice passthrough="false" type="DVD" hotpluggable="false" port="1" device="0"/>
      </StorageController>
      <StorageController name="SATA" type="AHCI" PortCount="1" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
        <AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
          <Image uuid="{86707f79-b0ca-4eb4-8e5e-330992e27cbf}"/>
        </AttachedDevice>
      </StorageController>
    </StorageControllers>
  </Machine>
</VirtualBox>

在虚拟电脑上安装ubuntu16.04.5

现在网络不做修改,安装完操作系统后再做修改

  1. 选择启动盘

    • "F:softwareubuntu-16.04.5-server-amd64.iso"
  2. Language

    • English
  3. Install Ubuntu Server

    • 全新安装Ubuntu服务器
  4. Select a language

    • English
  5. Select you location

    • other/Asia/China
  6. Configure locales

    • United States
    • -en_US.UTF-8
  7. Configure the keyboard

    • NO/English(US)/English(US)
  8. Configure the network

    • Hostname:youshengyouse
  9. Set up users and passwords

    • Full name for the new user: qianjin
    • username for your account:qianjin
    • choose a password for the new user: beijing2018
    • Encryp your home directory:<NO>
  10. Configure the clock

    • Is the time (asia/Chongqing) zone correct? <Yes>
  11. Partition disks 磁盘分区

    • Partitioning method: Manual
    • SCSI3(0,0,0)(sda)-10.7GB ATA VBOX HARDDISK
    • Create new empty partition table on this device:<Yes>
    • pri/log 10.7GB FREE SPACE

      • Create a new partition
      • New partition size: 6GB
      • Type for the new partition:Primary
      • Location for the new partition:Begining
      • Partition settings: Use as: Ext4,Mount point: /,Label:aaaa后Done setting up the partition
    • Pri/log 4.7GB FREE SPACE

      • Create a new partition
      • New partition size: 4GB
      • Type for the new partition:Logical
      • Location for the new partition:Begining
      • Partition settings: Use as: Ext4,Mount point: /home,Label:bbbb后Done setting up the partition
    • Pri/log 737.1MB FREE SPACE

      • Create a new partition
      • New partition size: 737.1MB
      • Type for the new partition:Logical
      • Location for the new partition:Begining
      • Partition settings: Use as:swap area后Done setting up the partition
      • Finish partitioning and write changes to disk
      • <Yes>
  12. Configure the package manager

    • Http proxy information (blank for none) :留空
  13. Configuring tasksel

    • No automatic updates
  14. software selection

    • choose software to install: 有

      • Manual package selection
      • DNS server
      • LAMP server
      • Mail server
      • PostgreSQL database
      • Samba file server
      • [*]Standard system utilities
      • Virtual Machine host
      • OpenSSH 5-server-amd64
  15. Install the GRUB boot loader on a hard disk

    • Install the GRUB boot loader to the master boot record?<Yes>

ubuntu中可以ping www.baidu.com,表明可以上网,虚拟机/设置/网络/网卡1的连接方式为网络地址转换(NAT),暂不修改,先安装openssh server实现使用xshell远程登录

安装openssh-server

sudo apt-get install openssh-server

选择虚拟电脑> 设置 > 网络 > 网卡1 >端口转发 222->22,重启,现在就可以远程连接到虚拟电脑了

安装增强功能

参考文档1: 如何14.04上安装增强功能(有些过时,仅参考)
参考文档2

  1. 分配光驱

    • 启动虚拟机>设备>分配光驱>"E:/Program Files/Oracle/VirtualBox/VBoxGuestAdditions.iso"

        qianjin@youshengyouse:~$ blkid
        // 在/dev/sr0上
        /dev/sr0: UUID="2018-08-14-11-58-42-18" LABEL="VBox_GAs_5.2.18" TYPE="iso9660"
        /dev/sda1: LABEL="aaaa" UUID="b7dfc546-5829-4fa4-ba44-4d40646b05f6" TYPE="ext4"       PARTUUID="00144287-01"
        /dev/sda5: LABEL="bbbb" UUID="7e67844a-4bd6-4a5a-81d5-a550759353e6" TYPE="ext4"       PARTUUID="00144287-05"
        /dev/sda6: UUID="96dade26-df03-48af-896b-e25dbf6bd13b" TYPE="swap" PARTUUID="00144287-06"
    • 挂载设备到目录

      qianjin@youshengyouse:~$ cd ~ && mkdir mycdrom && sudo mount /dev/sr0  ~/mycdrom && cd mycdrom && ls -l
      mount: /dev/sr0 is write-protected, mounting read-only
      total 49678
      dr-xr-xr-x 2 root root      480 Aug 14 19:58 32Bit
      dr-xr-xr-x 2 root root      480 Aug 14 19:58 64Bit
      -r--r--r-- 1 root root      763 Nov 28  2017 AUTORUN.INF
      -r-xr-xr-x 1 root root     6384 Aug 14 19:51 autorun.sh
      dr-xr-xr-x 2 root root      792 Aug 14 19:58 cert
      dr-xr-xr-x 2 root root     2508 Aug 14 19:58 OS2
      -r-xr-xr-x 1 root root     4821 Aug 14 19:51 runasroot.sh
      -r--r--r-- 1 root root      449 Aug 14 19:58 TRANS.TBL
      -r-xr-xr-x 1 root root  7321037 Aug 14 19:51 VBoxLinuxAdditions.run
      -r--r--r-- 1 root root 16442880 Aug 14 20:52 VBoxSolarisAdditions.pkg
      -r-xr-xr-x 1 root root 16506688 Aug 14 19:58 VBoxWindowsAdditions-amd64.exe
      -r-xr-xr-x 1 root root   268504 Aug 14 19:51 VBoxWindowsAdditions.exe
      -r-xr-xr-x 1 root root 10312360 Aug 14 19:52 VBoxWindowsAdditions-x86.exe
  2. 安装

    qianjin@youshengyouse:~/mycdrom$ sudo  ./VBoxLinuxAdditions.run
    Verifying archive integrity... All good.
    Uncompressing VirtualBox 5.2.18 Guest Additions for Linux........
    VirtualBox Guest Additions installer
    Copying additional installer modules ...
    Installing additional modules ... 安装附加模块
    VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.  This may take a while.
    This system is currently not set up to build kernel modules. 该系统没有设置好核心模块
    Please install the gcc make perl packages from your distribution. 请安装包gcc make perl 
    VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted
    VirtualBox Guest Additions: Starting.

    没安装成功,原来要安装dkms

    // 针对server版
    sudo apt-get update
    sudo apt-get install virtualbox-guest-dkms 
    qianjin@youshengyouse:~/mycdrom$ sudo  ./VBoxLinuxAdditions.run
    Verifying archive integrity... All good.
    Uncompressing VirtualBox 5.2.18 Guest Additions for Linux........
    VirtualBox Guest Additions installer
    Removing installed version 5.2.18 of VirtualBox Guest Additions...
    Copying additional installer modules ...
    Installing additional modules ...
    VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.  This may take a while.
    VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted 重启后起作用
    VirtualBox Guest Additions: Starting.
  3. 验证是否安装成功

    qianjin@youshengyouse:~$  lsmod  | grep -io vboxguest
    vboxguest

宿主机与虚拟机共享文件目录

  • 启动虚拟机>设置>共享文件夹>名称:fangshuixiushan,目录 F:\www\a_fangshuixiushan
  • 挂载共享(针对分区类型不是lvm的)

    // qianjin@youshengyouse:~$ sudo mkdir -p /var/www/fangshuixiushan && sudo mount.vboxsf 
    fangshuixiushan /var/www/fangshuixiushan
    // 编辑/etc/fstab,不要选择自动挂载,另外先要创建好挂载目录
    fangshuixiushan /var/www/qianjin vboxsf rw,gid=100,uid=1000,auto 0 0
    • 当在设备/共享文件夹>中选择了自动挂载,如果分区类型是lvm时,会在/media下自动生成生成共享文件目录
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/bogon--vg-root /               ext4    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=353af228-e685-4d3c-9abf-989898e42fce /boot           ext2    defaults        0       2
/dev/mapper/bogon--vg-swap_1 none            swap    sw              0       0
qj /var/www/qianjin vboxsf rw,gid=100,uid=1000,auto 0 0
cms-fangshuixiushan /var/www/cms/fangshuixiushan vboxsf rw,gid=100,uid=1000,auto 0 0
store-jihuizhenghao /var/www/store/jihuizhenghao vboxsf rw,gid=100,uid=1000,auto 0 0

五:安装Docker和Docker-compose

07. Docker安装参考文档
08. Docker-compose安装参考文档
git

安装docker-ce

安装时间:2018-09-18

qianjin@youshengyouse:~$ sudo apt-get remove docker docker-engine docker.io //卸载旧版本docker
qianjin@youshengyouse:~$ sudo apt-get update
qianjin@youshengyouse:~$ sudo apt-get install  apt-transport-https ca-certificates software-properties-common //已是最新版本了
qianjin@youshengyouse:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - //添加官方的GPG kye
qianjin@youshengyouse:~$ sudo apt-key fingerprint 0EBFCD88 //验证 fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 的key
qianjin@youshengyouse:~$ sudo add-apt-repository   "deb [arch=amd64] https://download.docker.com/linux/ubuntu   $(lsb_release -cs)  stable" //添加stable仓库
qianjin@youshengyouse:~$ sudo apt-get update
qianjin@youshengyouse:~$ sudo apt-get install docker-ce //安装docker-ce,用时不到1分钟
qianjin@youshengyouse:~$ sudo docker run hello-world //运行第一个容器,检查docker是否安装ok
qianjin@youshengyouse:~$ sudo usermod -aG docker $USER //现在不用每次都输入sudo了,直接docker

// dev.aliyun.com登录进去找到自己的加速器
qianjin@youshengyouse:~$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://d7xucqac.mirror.aliyuncs.com"]
}
EOF

安装docker-compose

安装时间:2018-09-18

qianjin@youshengyouse:~$ sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose //下载
qianjin@youshengyouse:~$ sudo chmod +x /usr/local/bin/docker-compose //有执行权限
qianjin@youshengyouse:~$ docker-compose --version //当前版本是docker-compose version 1.22.0, build f46880f

使用devilbox搭建开发环境

参考来源
参考来源(中文)

六:安装社交类软件

微信
qq
阿里旺旺

七:网站建设类

破解win10和office的 KMSpico
xshell
winscp
git
TortoiseSVN
nodejs
chrome
phpstorm
sublime
navicat for mysql
微信开发助手

八:设计、办公及字体

office2016
adobe系列+perfect Mask5.2
coreldraw x4

九:其它

Dev C++
百度网盘
迅雷
华为手机助手
爱奇艺
汉王ocr
Zend studio
阅读 5.4k

推荐阅读