【Linux】拿到一台新的Ubuntu系统,你需要准备些什么?

1、开启端口

查看已经开启的端口

shell 复制代码
sudo ufw status

打开端口

shell 复制代码
sudo ufw allow 3306

开启防火墙

shell 复制代码
sudo ufw enable

重启防火墙

shell 复制代码
sudo ufw reload

再次查看一下端口是否已开放

shell 复制代码
sudo ufw status

2、安装Docker

卸载旧版本 Docker

shell 复制代码
sudo apt-get remove docker \
     docker-engine \
     docker.io

apt更新

shell 复制代码
sudo apt-get update

下载安装时必要工具

shell 复制代码
sudo apt-get install \
     apt-transport-https \ 
     ca-certificates \ 
     curl \
     gnupg-agent \
     software-properties-common

添加软件源的 GPG 密钥 (Aliyun 和 官方 二选一)

Aliyun

shell 复制代码
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -

官方

shell 复制代码
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sources.list 中添加 Docker 软件源 (Aliyun 和 官方 二选一)

Aliyun

shell 复制代码
sudo add-apt-repository \
     "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu \
     $(lsb_release -cs) \
     stable"

官方

shell 复制代码
sudo add-apt-repository \ 
     "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
     $(lsb_release -cs) \ 
     stable"

安装 Docker , 使用脚本自动安装

shell 复制代码
sudo apt-get update 

sudo apt-get install docker-ce docker-ce-cli containerd.io

curl -fsSL get.docker.com -o get-docker.sh 

sudo sh get-docker.sh --mirror Aliyun

启动 Docker

shell 复制代码
sudo systemctl enable docker

sudo systemctl start docker

3、Docker 安装 Mysql Redis Portainer

安装Mysql

shell 复制代码
# 搜索 Mysql 镜像
docker search mysql:5.7

# 拉取 Mysql 镜像
docker pull mysql:5.7
  
# 启动 Mysql 容器 
docker run -d \
  --name tcs_mysql \
  -p 3306:3306 \
  -e MYSQL_ROOT_PASSWORD=cat888 \
  --character-set-server=utf8mb4 \
  --collation-server=utf8mb4_general_ci \
  mysql:5.7

安装 Redis

shell 复制代码
# 拉取 Redis 镜像
docker pull redis

# 拉取配置
wget http://download.redis.io/redis-stable/redis.conf
  
# 启动 Reids
docker run --name redis \
-p 6379:6379 \
-v /docker-data/redis/redis.conf:/etc/redis/redis.conf \
-v /docker-data/redis:/data \
-d redis redis-server /etc/redis/redis.conf --appendonly yes
相关推荐
李少兄2 小时前
CentOS系统下前后端项目部署攻略
linux·运维·centos
Two_brushes.5 小时前
【Linux】线程机制深度实践:创建、等待、互斥与同步
linux·运维·服务器·多线程
尘土哥6 小时前
Docker 快速上手
docker·容器·eureka
设计师小聂!7 小时前
Linux系统中部署Redis详解
linux·运维·数据库·redis
kfepiza7 小时前
Debian-10编译安装Mysql-5.7.44 笔记250706
linux·数据库·笔记·mysql·debian·bash
广州山泉婚姻7 小时前
Docker从环境配置到应用上云的极简路径
docker
努力做小白8 小时前
Linux驱动11 --- buildroot&杂项驱动开发方法
linux·运维·驱动开发·单片机·嵌入式硬件
帽儿山的枪手9 小时前
追踪网络流量就这么简单 | 进阶篇 | conntrack
linux·windows·网络协议
哈哈浩丶9 小时前
Linux驱动开发1:设备驱动模块加载与卸载
linux·运维·驱动开发
Bulestar_xx9 小时前
20250711_Sudo 靶机复盘
linux·安全·web安全