本文最后更新于 2025年4月25日 下午
背景
不小心把服务器mysql数据删除了,之前用宝塔面板无脑装的可道云用不了了,考虑到服务器上也没有什么重要的内容,决定重装系统,顺便把可道云换成docker版的,把我必装的一部分软件和配置都记录一下,有些软件安装之前已经写过文章,这里可能重复了,但这算是一个汇总版
安装过程
- rufus制作启动U盘选择GPT分区
- bios选择U盘启动
- 安装时文件系统选择NTFS
- 磁盘分区时在free空间单独分配出给/home的空间,剩余的修改/目录的分配大小,写一个超过硬盘大小的空间把剩余的都分配给/
系统设置
root密码
允许root远程ssh登录
1 2 3
| vim /etc/ssh/ssh_config PermitRootLogin yes port xxxx
|
更改软件源
清华源官方:https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/
修改/etc/apt/sources.list.d/ubuntu.sources
为:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble noble-updates noble-backports # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换 Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble-security # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# 预发布软件源,不建议启用
# Types: deb # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble-proposed # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
# # Types: deb-src # # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # # Suites: noble-proposed # # Components: main restricted universe multiverse # # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
1 2
| sudo apt update sudo apt upgrade
|
设置时区
1 2 3
| date sudo timedatectl set-timezone Asia/Shanghai date
|
安装软件
v2raya
官方文档https://v2raya.org/docs/prologue/installation/docker/
之前写过的文章https://xinhaojin.github.io/2025/01/01/ubuntu%E4%B8%8B%E9%85%8D%E7%BD%AEv2raya/
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| docker pull mzz2017/v2raya docker run -d \ --restart=always \ --privileged \ --network=host \ --name v2raya \ -e V2RAYA_LOG_FILE=/tmp/v2raya.log \ -e V2RAYA_V2RAY_BIN=/usr/local/bin/xray \ -e V2RAYA_NFTABLES_SUPPORT=off \ -e IPTABLES_MODE=legacy \ -v /lib/modules:/lib/modules:ro \ -v /etc/resolv.conf:/etc/resolv.conf \ -v /etc/v2raya:/etc/v2raya \ mzz2017/v2raya
|
proxychains4
1
| sudo apt install proxychains4
|
编辑/etc/proaychains4.conf
添加
1
| http 192.168.31.100 10808
|
docker
1 2 3 4 5 6
| sudo apt install apt-transport-https ca-certificates curl software-properties-common -y echo "deb [arch=$(dpkg --print-architecture)] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y sudo usermod -aG docker username # 授权普通用户使用 systemctl enable docker #开机启动
|
更改docker镜像源,修改/etc/docker/daemon.json
1 2 3 4 5 6
| { "registry-mirrors": [ "https://docker.1ms.run", "https://docker.xuanyuan.me" ] }
|
1 2
| systemctl daemon-reload systemctl restart docker
|
miniconda
1 2 3 4 5
| wget -P /home/user/download https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh cd /home/user/download bash Miniconda3-latest-Linux-x86_64.sh source ~/.bashrc conda init
|
pip换源,~/.pip/pip.conf
1 2 3 4 5 6 7 8 9
| [global] index-url = https: extra-index-url = https: http:
[install] trusted-host = pypi.mirrors.ustc.edu.cn pypi.tuna.tsinghua.edu.cn mirrors.aliyun.com
|
hexo
1 2 3 4 5 6
| npm install -g hexo-cli mkdir blog cd blog hexo init npm install hexo-theme-fluid --save npm install hexo-deployer-git --save
|
mysql
1 2 3 4
| docker pull mysql:8.3.0 mkdir -p /home/jxh/mysql/{conf,data,log} cd /home/jxh/mysql/conf vim my.cnf
|
my.cnf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| [client] #设置客户端默认字符集utf8mb4 default-character-set=utf8mb4 [mysql] #设置服务器默认字符集为utf8mb4 default-character-set=utf8mb4 [mysqld] #配置服务器的服务号,具备日后需要集群做准备 server-id = 1 #开启MySQL数据库的二进制日志,用于记录用户对数据库的操作SQL语句,具备日后需要集群做准备 log-bin=mysql-bin #设置清理超过30天的日志,以免日志堆积造过多成服务器内存爆满。2592000秒等于30天的秒数 binlog_expire_logs_seconds = 2592000 #解决MySQL8.0版本GROUP BY问题 sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' #允许最大的连接数 max_connections=1000 # 禁用符号链接以防止各种安全风险 symbolic-links=0 # 设置东八区时区 default-time_zone = '+8:00' ```shell docker run \ -p 3306:3306 \ --restart=always \ --name mysql \ --privileged=true \ -v /home/jxh/mysql/log:/var/log/mysql \ -v /home/jxh/mysql/data:/var/lib/mysql \ -v /home/jxh/mysql/conf/my.cnf:/etc/mysql/my.cnf \ -e MYSQL_ROOT_PASSWORD=12345678 \ -d mysql:8.3.0 docker exec -it mysql bash mysql -u root -p
|
nginx
nodejs
添加nodejs仓库,获得最新的nodejs版本
1
| curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
安装nodejs
1 2 3 4
| sudo apt install nodejs node -v npm -v npm config set registry https://registry.npmmirror.com
|
kodbox
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| sudo apt install docker-compose docker-compose up -d docker rename kodbox_app_1 kodbox docker exec -it kodbox bash vi /etc/nginx/nginx.conf client_max_body_size 8G; client_header_timeout 3600s; client_body_timeout 3600s; fastcgi_connect_timeout 3600s; fastcgi_send_timeout 3600s; fastcgi_read_timeout 3600s; printenv | grep PHP_INI_DIR vi /usr/local/etc/php/php.ini-production post_max_size = 8G; upload_max_filesize = 8G; memory_limit = 8G; max_execution_time = 3600; max_input_time = 3600; vi /usr/local/etc/php-fpm.d/www.conf request_terminate_timeout 3600 php_admin_value[memory_limit] = 8G
|
rclone
1 2
| sudo apt-get install rclone rclone config
|
其他
略