Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JoJoJotarou/160079e28e5f9240fdedfbb9c9be2038 to your computer and use it in GitHub Desktop.
Save JoJoJotarou/160079e28e5f9240fdedfbb9c9be2038 to your computer and use it in GitHub Desktop.
在Linux上部署开发环境的一份指南(尽量提供一键脚本)

💡使用 root 或具有 sudo 权限的用户 💡默认你正在配置一个新的环境,若不是则按需执行

apt 更换阿里云源

# debian 11.3
sudo sed -ri 's/(deb|security|ftp).debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && sudo apt update

sudo

debian 默认是没有 sudo 命令的,先下载命令:

apt insatll sudo

dev 用户设置管理员权限, 执行 vim /etc/sudoers,添加如下行:

dev   ALL=(ALL:ALL) ALL

timezone

sudo timedatectl set-timezone Asia/Shanghai

开发环境

JDK

update-alternatives 用法

# jdk17 清华源
   sudo wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/17/jdk/x64/linux/OpenJDK17U-jdk_x64_linux_hotspot_17.0.3_7.tar.gz -O /tmp/jdk17.tar.gz \
&& sudo rm -rf /usr/local/jdk/jdk17 \
&& sudo mkdir -p /usr/local/jdk/jdk17 \
&& sudo tar -zxf /tmp/jdk17.tar.gz -C /usr/local/jdk/jdk17 --strip-components 1 \
&& sudo rm /tmp/jdk17.tar.gz \
&& sudo update-alternatives --install /usr/local/jdk/current jdk /usr/local/jdk/jdk17 17

# jdk8 清华源
   sudo wget https://mirrors.tuna.tsinghua.edu.cn/Adoptium/8/jdk/x64/linux/OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz -O /tmp/jdk8.tar.gz \
&& sudo rm -rf /usr/local/jdk/jdk8 \
&& sudo mkdir -p /usr/local/jdk/jdk8 \
&& sudo tar -zxf /tmp/jdk8.tar.gz -C /usr/local/jdk/jdk8 --strip-components 1 \
&& sudo rm /tmp/jdk8.tar.gz \
&& sudo update-alternatives --install /usr/local/jdk/current jdk /usr/local/jdk/jdk8 8

# jdk17
   sudo wget https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.3%2B7/OpenJDK17U-jdk_x64_linux_hotspot_17.0.3_7.tar.gz -O /tmp/jdk17.tar.gz \
&& sudo rm -rf /usr/local/jdk/jdk17 \
&& sudo mkdir -p /usr/local/jdk/jdk17 \
&& sudo tar -zxf /tmp/jdk17.tar.gz -C /usr/local/jdk/jdk17 --strip-components 1 \
&& sudo rm /tmp/jdk17.tar.gz \
&& sudo update-alternatives --install /usr/local/jdk/current jdk /usr/local/jdk/jdk17 17

# jdk8
   sudo wget https://github.com/adoptium/temurin8-binaries/releases/download/jdk8u332-b09/OpenJDK8U-jdk_x64_linux_hotspot_8u332b09.tar.gz -O /tmp/jdk8.tar.gz \
&& sudo rm -rf /usr/local/jdk/jdk8 \
&& sudo mkdir -p /usr/local/jdk/jdk8 \
&& sudo tar -zxf /tmp/jdk8.tar.gz -C /usr/local/jdk/jdk8 --strip-components 1 \
&& sudo rm /tmp/jdk8.tar.gz \
&& sudo update-alternatives --install /usr/local/jdk/current jdk /usr/local/jdk/jdk8 8

Maven

Maven Downloading Page

   sudo wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz -O /tmp/maven.tar.gz \
&& sudo rm -rf /usr/local/maven \
&& sudo mkdir -p /usr/local/maven \
&& sudo tar -zxf /tmp/maven.tar.gz -C /usr/local/maven  --strip-components 1 \
&& sudo rm /tmp/maven.tar.gz

Tomcat

Tocmat 官方(左侧菜单Download项有不同版本)

   sudo wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.64/bin/apache-tomcat-9.0.64.tar.gz -O /tmp/tomcat9.tar.gz \
&& sudo rm -rf /usr/local/tomcat/tomcat9 \
&& sudo mkdir -p /usr/local/tomcat/tomcat9 \
&& sudo tar -zxf /tmp/tomcat9.tar.gz -C /usr/local/tomcat/tomcat9  --strip-components 1 \
&& sudo rm /tmp/tomcat9.tar.gz

设置环境变量

当前用户 dev, 若希望全局使用 root,并将 ~/.bashrc 改为 /etc/profile

sed -i '$ a # jdk\nexport JAVA_HOME=/usr/local/jdk/current\nexport PATH=$JAVA_HOME/bin:$PATH\n# maven\nexport PATH=/usr/local/maven/bin:$PATH' ~/.bashrc \
&& source ~/.bashrc

最后

痛斥以下腾讯云访问海外服务器的网络速度:

首先,我的腾讯云配置: 腾讯云配置

腾讯云下载速度:

腾讯云下载速度

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment