目录


Ubuntu Server


1 下载与安装

1.1 下载地址

Ubuntu官网下载: http://cdimage.ubuntu.com/releases/18.04/release/
我这里采用的版本为 Ubuntu Server 18.04.1 LTS

1.2 安装

和安装win server一样,先镜像上传到ESXI,然后直接新建虚拟机就可以了。硬件配置我分配了2G内存和20G硬盘。
加载完毕后,选择语言、选择安装位置、选择引导位置,然后等待安装结束重启。

2 后续配置

2.1 设置root密码

sudo passwd root

Password:你当前的密码
Enter new UNIX password:这个是root的密码
Retype new UNIX password:重复root的密码

2.2 设置静态IP

Ubuntu18.04采用的是netplan来管理network。所以可以在/etc/netplan/目录下创建一个以yaml结尾的文件。比如01-netplan.yaml文件。
然后在此文件下写入以下配置(注意保留空格缩进):

network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: no
      addresses: [192.168.1.102/24]
      gateway4:  192.168.1.1
      nameservers:
        addresses: [8.8.8.8, 114.114.114.114]

然后重启网络

sudo netplan apply

2.3 修改时区

输入timedatectl status如果显示的时间不对,则使用如下命令修改时区

sudo timedatectl set-timezone 'Asia/Shanghai'

2.4 更新系统,升级应用

添加更新源。服务器版的ubuntu更新源很少,需要吧一些常用的更新源添加进去

sudo vi /etc/apt/sources.list

# 在最后添加下列源,并保存: #######################################
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse

# 163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
# ######################################################################

更新源及系统:

sudo apt-get update
sudo apt-get upgrade
  • 如果update出错
sudo vim /etc/resolv.conf
把nameserver的值换为8.8.8.8

再重启网络服务

/etc/init.d/networking restart

2.5 挂载nas盘

  • 挂载
sudo apt-get install nfs-common
cd ~
sudo mkdir nfs
cd nfs
sudo mkdir Download
sudo mount -t nfs 192.168.1.100:/Download /home/username/nfs/Download

# 添加开机自动挂载
sudo vim /etc/fstab

# 在文件最后加上下面内容
192.168.1.100:/Download /home/username/nfs/Download nfs defaults 0 0

  • 卸载
sudo umount 192.168.1.100:/Download /home/username/nfs/Download

3 安装必要的软件

sudo apt-get install gcc
sudo apt-get install g++
sudo apt-get install make
sudo apt-get install unzip
sudo apt-get install apache2
sudo apt-get install -y php7.2
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐