记录一下Ubuntu下服务环境部署

前言:最近

配置apt源为阿里云

1、备份你的旧源文件:

1
$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、检查系统内核版本号

1
$ sudo lsb_release -a

得到如下回显:

1
2
3
4
5
6
root@uosoubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy

这里的jammy就是当前服务器的版本号

3、设置阿里云源

  • 编辑 /etc/apt目录下的sources.list文件,填入以下内容

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    #  阿里源
    deb http://mirrors.aliyun.com/ubuntu/ version main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ version-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ version-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ version-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ version-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ version main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ version-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ version-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ version-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ version-backports main restricted universe multiverse

  • 将填入内容中的version字段替换为当前系统版本号,即如下格式

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    #  阿里源
    deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
  • 刷新 apt 列表

    1
    $ sudo apt update

Ubuntu安装JDK8

1
$ sudo apt-get install openjdk-8-jdk

Ubuntu安装Nginx

  • 安装

    1
    $ sudo apt install nginx
  • 启动和部署

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # 启动Nginx
    $ sudo systemctl start nginx

    # 查看Nginx状态
    $ sudo systemctl status nginx

    # 配置开机自启
    $ sudo systemctl enable nginx

    # 检查配置文件
    $ sudo nginx -t

    # 刷新Nginx
    $ sudo nginx -s reload