虚拟机安装Debian12搭建Web服务器

2024-12-15 13:54 栏目: 技术学堂 查看()

Debian作为一款广受推崇的Linux操作系统,以其高度的稳定性、强大的软件库以及丰富的社区支持而著称。无论是个人用户,还是企业级用户,都能从Debian中受益。为什么我们需要选择Debian?如何安装它?本文将详细介绍Debian的安装流程,利用宝塔搭建WEB服务器。

1.从阿里云下载安装文件:https://mirrors.aliyun.com/debian-cd/12.8.0-live/amd64/iso-hybrid/debian-live-12.8.0-amd64-standard.iso


00.png

2.如下图安装:


01.png

3.选择英文:


02.png


4:先择美国:


03.png


5.语言选英语


04.png


6.输入此系统的主机名,主机名是在网络中识别您的系统的一个单词。如果您不知道主机名是什么,请询问网络管理员。如果您正在设置家庭网络,那么可以随意写个名字。


05.png


7.选择域名,可以跳过:


06.png


8.为 root 创建一个密码


07.png


9.创建一个非 root 用户


08.png


10. 创建非 root  帐户密码


09.png


11.选择时区,随便选一个


10.png


12.分区磁盘,选择第一项:整个磁盘分区


11.png


13.分区方案,选第一项。


12.png


14.默认系统分区方案,完成分区并写入系统。


13.png


15.选择“是”,完成分区:


14.png


16.选择镜像源,后续可以安装软件包。


15.png


17.选择国内的镜像源


16.png


18.任意选一个国内的镜像源


17.png


19.跳过代理服务器设置。


18.png


20.选择“是”完成启动引导。


19.png


21.选择启动的分区


20.png


22.完成最后的安装。


21.png


23.完成后用 root 帐号登录,ip a  命令察看网卡信息。 IP为: 192.168.177.130


22.png


24.此时用FTP软件登录是失败的,说明没开启SSH。


23.png



24.png


25.开启SSH:   

sudo apt update

安装OpenSSH服务器软件包:

sudo apt install openssh-server

启动SSH服务:

sudo systemctl start ssh

确保SSH服务在启动时自动运行:

sudo systemctl enable ssh

(可选)如果你想检查SSH服务的状态,可以使用:

sudo systemctl status ssh


25.png

26.png


26.开启后再用 ftp  软件远程登录,显示拒绝 root 帐号登录。


27.png


27.Debian 12 中,SSH 默认可能不允许 root 用户通过 SSH 进行远程登录。为了启用 root 用户的 SSH 远程登录,你需要进行以下步骤:

编辑 SSH 配置文件 /etc/ssh/sshd_config。

sudo nano /etc/ssh/sshd_config

找到 PermitRootLogin 这一行,并将其修改为:

PermitRootLogin yes

如果该行以 # 开头,则去掉 # 以取消注释并修改。

保存并关闭文件,然后重启 SSH 服务以应用更改:

sudo systemctl restart sshd

请注意,出于安全考虑,通常不推荐允许 root 用户通过 SSH 远程登录。考虑使用其他安全措施,如 SSH 密钥认证和 Fail2Ban 来增强安全性。


28.png


28.更换为阿里云镜像源: /etc/apt/sources.list


deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib

deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib

deb https://mirrors.aliyun.com/debian-security/ bookworm-security main

deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main

deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib

deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib

deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib

deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib


29. 图形界面是基于x-window的,再安装 Kde或Gnome

sudo apt update

sudo apt install x-window-system-core

sudo apt install gdm3 gnome

通过本文介绍的安装步骤和优势分析,相信你对Debian已经有了更清晰的认识。无论是作为个人用户,还是企业用户,Debian都能够为你提供一个安全、可靠、可定制的操作系统环境。

扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流

郑重申明:宁波优景摄影以外的任何单位或个人,不得使用该案例作为工作成果展示!