Post cover

前端环境搭建之Linux

Author AvatarYuhang
2025年3月1日

上一篇讲了VM Ware 云开发环境的基础配置, 这里再记录一下前端开发系统中软件环境的基础准备 ,包括系统配置的常用工具安装。 这里基于我常使用的Debian12.6系统

1. 系统准备

首先需要更换一下国内的软件源:

Bash
1# 切换到root用户 2su - 3 4# 备份软件源配置 5cp /etc/apt/sources.list /etc/apt/sources.list.bak 6 7# 替换为阿里云源 8deb https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib 9deb-src https://mirrors.aliyun.com/debian/ bookworm main non-free non-free-firmware contrib 10deb https://mirrors.aliyun.com/debian-security/ bookworm-security main 11deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main 12deb https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib 13deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main non-free non-free-firmware contrib 14deb https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib 15deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main non-free non-free-firmware contrib 16 17# 更新软件包列表 18apt update 19 20# 安装常用工具 21apt install zsh git curl vim sudo 22 23# 将当前用户添加到sudo组 24usermod -aG sudo $USER

2. 用户配置

为了方便日常使用,我们需要对当前用户进行一些配置:

Bash
1# 配置Git全局设置 2git config --global user.name "username" 3git config --global user.email "email" 4git config --global core.editor "vim"

记得将上面的用户名和邮箱替换成你自己的。

3. 网络代理设置

如果你需要使用代理,可以设置环境变量:

Bash
1export http_proxy="http://localhost:7890"; 2export https_proxy="http://localhost:7890";

4. Shell优化

使用Oh My Zsh增强zsh的功能:

Bash
1# 将默认shell更改为zsh 2chsh -s $(which zsh) 3 4# 安装Oh My Zsh 5sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 6

5. Node.js环境配置

使用nvm来管理Node.js版本:

Bash
1# 安装nvm 2curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash 3 4# 安装Node.js 20版本 5nvm install 20 6 7# 安装常用的全局包 8npm i -g nrm pm2 pnpm 9 10# 使用淘宝镜像源 11nrm use taobao

6. 远程组网

Tailscale是一个很好的VPN替代品,可以方便地连接你的所有设备:

Bash
1curl -fsSL https://tailscale.com/install.sh | sh

7. 其他优化

后面再慢慢补充,基础的软件就这些了,可以满足开发的使用了

0

Likes

加载评论中...