开发中的常用命令场景

一、新服务器上的环境配置

安装python环境;

linux 软件包更新;

安装docker;

apt install python3.10

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3.10 get-pip.py

sudo apt update
sudo apt install lsb-release
sudo apt install software-properties-common

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update

#可能有问题   需要   sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7EA0A9C3F273FCD8

 curl -fsSL https://test.docker.com -o test-docker.sh
 sudo sh test-docker.sh

sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose

sudo systemctl status docker
sudo systemctl start docker

root:/home/test# python3 --version
Python 3.10.12
root:/home/test# docker --version
Docker version 20.10.24, build 297e128
root:/home/test# docker-compose --version
Docker Compose version v2.17.2

二、安装 conda 环境

./Miniconda3-latest-Linux-x86_64.sh

conda install anaconda-client -n base

conda create -n sql python=3.8

source ~/.bashrc

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

三、Ubuntu 配置 nginx

Install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release ubuntu-keyring

Import an official nginx signing key so apt could verify the packages authenticity. Fetch the key:

curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
    | sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Verify that the downloaded file contains the proper key:

gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg

The output should contain the full fingerprint 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 as follows:

pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>

If the fingerprint is different, remove the file.

To set up the apt repository for stable nginx packages, run the following command:

echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu lsb_release -cs nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

Set up repository pinning to prefer our packages over distribution-provided ones:

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

To install nginx, run the following commands:

sudo apt update
sudo apt install nginx

四、conda 环境打包

conda install -c conda-forge conda-pack

conda pack -o sqlenv.tar.gz

mkdir sqlenv
tar -xzf sqlenv.tar.gz -C sqlenv

source sqlenv/bin/activate

五、拓展文件空间

sudo lsblk -f
sudo resize2fs /dev/vdb

六、切换github token

git remote -v
git remote rm origin
git remote add origin https://<new token>@github.com/<github name>/仓库名.git

京ICP备2023033280号