由于当前服务器宽带较低,目前正在考虑博客迁移,顺便完整记录新服务配置流程。
本文出现的所有指令均基于Debian系统,本文操作指令仅做参考。
同时会尽量标注官方指令地址(如有)。
- 云服务器 重装系统 >> Debian12
更新
♾️ sh 代码:sudo apt update sudo apt upgrade
安装Docker
♾️ sh 代码:
优先使用官方文档推荐的命令:官方文档地址# 配置 sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.asc echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # 更新软件包配置 sudo apt-get update # 执行安装 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # 验证指令 docker images docker ps
安装Nginx
♾️ sh 代码:sudo apt install nginx # 验证 systemctl status nginx
安装Php
♾️ sh 代码:sudo apt install php # 安装PHP-FPM(版本与PHP保持一致) sudo apt install php8.2-fpm # 验证 php -v
安装Mysql
♾️ sh 代码:# 前往官网获取最新软件包连接:https://dev.mysql.com/downloads/repo/apt/ wget https://dev.mysql.com/get/mysql-apt-config_0.8.33-1_all.deb sudo apt install gnupg -y sudo dpkg -i mysql-apt-config_0.8.33-1_all.deb # 更新配置包 sudo apt update # 安装 sudo apt install mysql-server # 验证 sudo systemctl status mysql # 修改访问权限 sudo mysql -uroot -p use mysql; update user set Host = '%' where User = 'root'; FLUSH PRIVILEGES; exit;
使用容器安装
♾️ sh 代码:# 略...
配置Typecho
♾️ sh 代码:# 官网下载文件并上传到服务(作者地址为/www/html/ty/...):https://typecho.org/download sudo apt install unzip unzip typecho.zip # 修改权限 sudo chmod -R 777 /www/html/ty/usr/ ## 安装相关扩展 sudo apt install php-mbstring sudo apt install php-mysql # 安装完成后请重启 sudo systemctl restart php8.2-fpm
配置Nginx
♾️ sh 代码:nano /etc/nginx/conf.d/main.conf # 新增配置文件并写入 server { listen 80; server_name 域名或者IP; root /www/html/ty; # 博客解压地址 index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; # 替换为自己的版本 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } systemctl restart nginx