丝甲坞 发表于 2025-8-17 18:30:22

Linux VPS 服务器环境搭建记录

本文记录 AlmaLinux OS 9 系统下个人服务器环境搭建过程,以便后续查阅。
服务器主要用作部署 Web 服务,生态为 Node.js 相关。
登入服务器

默认是以root用户登录的,之后会切换到普通用户,不再使用root用户登录
检查系统版本

uname -a
cat /etc/redhat-release
lsb_release -a
hostnamectl配置用户

添加普通用户

用户名自行修改并设置密码
useradd -m -s /bin/bash yumine
passwd yumine授予普通用户 sudo 权限

tee /etc/sudoers.d/yumine <<< 'yumine ALL=(ALL) ALL'
chmod 440 /etc/sudoers.d/yumine切换到普通用户

接下来的命令都切换到刚才新建的普通用户下运行,用户名改成自己的
vi /etc/selinux/config
sestatus确认 GCC 版本

firewall-cmd --permanent --zone=public --add-port=2333/tcp安装 Git

dnf install nano配置 nanorc

nano /etc/ssh/sshd_config安装 epel-release

PermitRootLogin no安装 nginx 并开放 HTTP(S) 端口

Port 2333安装 btop 和 ncdu

btop是资源监控工具,ncdu是磁盘占用检查工具
service sshd restart安装 Deno/Bun/Node.js

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
cat /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
lsmod | grep bbr安装常用 npm 包

su yuminepm2 使用

gcc --version
g++ --version安装 ffmpeg

方式一

sudo dnf install git
git --version方式二

dnf 里的版本可能比较老,如果需要新版本可以手动安装
链接到 https://github.com/BtbN/FFmpeg-Builds/releases 获取新的
curl https://raw.githubusercontent.com/scopatz/nanorc/master/install.sh | sh配置 .bashrc

然后编辑 ~/.bashrc ,将~/env路径添加到环境变量 Path 里,顺带配置一下 alias 和历史记录条数
sudo dnf install epel-release运行source ~/.bashrc后生效,之后就根据个人需要进行应用部署啦
SSH 工具推荐使用 Xterminal,编辑文件、传输文件、资源监控什么的都挺好用
Reference

https://p3terx.com/archives/improve-linux-server-security.html
https://p3terx.com/archives/add-normal-users-with-adduser-and-useradd.html
https://p3terx.com/archives/linux-nano-tutorial.html
fin.

来源:豆瓜网用户自行投稿发布,如果侵权,请联系站长删除
页: [1]
查看完整版本: Linux VPS 服务器环境搭建记录