You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用MobaXterm部署Node.js至AWS EC2时,amazon-linux-extras命令未找到求助

解决AWS EC2实例安装Nginx的命令问题

第一步:确认EC2实例的操作系统发行版

先执行命令查看系统类型,避免用错包管理器:

cat /etc/os-release

不同发行版对应的Nginx安装步骤

1. 若为Amazon Linux 2

  • 更新系统包:
    sudo yum update -y
    
  • 用专属工具安装Nginx:
    sudo amazon-linux-extras install nginx1 -y
    
  • 启动并设置开机自启:
    sudo systemctl start nginx
    sudo systemctl enable nginx
    

2. 若为Amazon Linux 2023

该版本已移除amazon-linux-extras,直接用dnf安装:

sudo dnf update -y
sudo dnf install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

3. 若为Ubuntu/Debian系列

  • 更新包索引:
    sudo apt update -y
    
  • 安装Nginx:
    sudo apt install nginx -y
    
  • 启动并设置开机自启:
    sudo systemctl start nginx
    sudo systemctl enable nginx
    

命令失败原因说明

  • amazon-linux-extras 是Amazon Linux 2独有的命令,其他发行版不存在。
  • 你输入的sudo app update是错误命令,不同系统对应正确包管理命令:Amazon Linux用yum/dnf,Ubuntu用apt。

内容的提问来源于stack exchange,提问作者Aswin Shaji

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 17:44:53