evant.me

返回文章列表

VPS初始化

  1. 安装sudo

    apt update
    
    apt-get install sudo
    
  2. 安装vim

    apt install vim
    
  3. 创建新用户并添加到用户组

    sudo adduser your_name
    
    sudo usermod -aG sudo your_name
    
  4. 本地生成密钥并复制

    ssh-keygen -t rsa -f key_name -C '[email protected]'
    
    ssh-copy-id -p ssh_port -i ~/.ssh/key_name.pub your_name@your_server_ip
    
    # 配置本地ssh config
    code ~/.ssh/config
    
    Host your_server_name
        User your_name
        HostName your_server_ip
        Port ssh_port
        IdentityFile ~/.ssh/key_name
    
  5. 配置ssh信息

    vi /etc/ssh/sshd_config
    
    Port ssh_port  # Change default port (use a number between 1024 and 65535)
    
    PermitRootLogin no # Disable root login
    
    PubkeyAuthentication yes # Enable public key authentication
    
    AuthorizedKeysFile .ssh/authorized_keys # Specify authorized_keys file location
    
    AllowUsers your_name # Only allow specific users to login
    
    PasswordAuthentication no # Disable password authentication
    
    service ssh restart # restart ssh
    
  6. 本地推送打包内容

    mkdir /apps/your_site_name
    
    sudo chown -R $USER /apps/your_site_name
    
    pnpm run build
    
    scp -r dist your_server_name:/apps/your_site_name
    
  7. 安装ufw

    sudo apt-get install ufw
    
    sudo ufw enable
    
  8. 安装nginx

    sudo apt install nginx
    
    sudo systemctl start nginx
    
    sudo ufw allow 80
    
    sudo ufw allow 443
    
    vim /etc/nginx/sites-available/default #配置root路径为 /apps/your_site_name
    
  9. 添加域名DNS A记录指向your_server_ip

  10. 安装snap

    sudo apt install snapd
    
    echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc
    
    source ~/.bashrc
    
  11. 安装配置certbot

    sudo snap install --classic certbot
    
    sudo ln -s /snap/bin/certbot /usr/bin/certbot
    
    sudo certbot --nginx
    
    sudo systemctl reload nginx
    
  12. 安装btop

    sudo snap install btop
    
  13. 安装v2ray备用

    bash <(wget -qO- -o- https://git.io/v2ray.sh)
    
    v2ray bbr # 开启bbr
    
    ufw allow v2ray_port/tcp
    

~

标题: VPS初始化

描述: 记录

发布日期: 2024年10月27日 22:30

~

RSS