LoginSignup
1
0

Amazon Linux 2023 で nginx をインストール

Posted at

Amazon Linux 2023 で nginx をインストールする方法

[つまづいた点] amazon-linux-extrasコマンドが廃止されている

Amazon Linux 2023 を初めて使おうと思い、 nginx をインストールするために
amazon- まで入力してタブを押したら出てきたのはこの2つのコマンドだけでした。

$ amazon-
amazon-chrony-config  amazon-ssm-agent

amazon-linux-extras コマンドは、Amazon Linux 2023 では廃止されているようです。

[解決] dnf コマンドでインストール

普通に dnf でインストールできそうです。

$ dnf search nginx

=================================================================== Name Exactly Matched: nginx ===================================================================
nginx.x86_64 : A high performance web server and reverse proxy server
================================================================== Name & Summary Matched: nginx ==================================================================
collectd-nginx.x86_64 : Nginx plugin for collectd
nginx-all-modules.noarch : A meta package that installs all available Nginx modules
nginx-core.x86_64 : nginx minimal core
nginx-filesystem.noarch : The basic directory layout for the Nginx server
nginx-mimetypes.noarch : MIME type mappings for nginx
nginx-mod-devel.x86_64 : Nginx module development files
nginx-mod-http-image-filter.x86_64 : Nginx HTTP image filter module
nginx-mod-http-perl.x86_64 : Nginx HTTP perl module
nginx-mod-http-xslt-filter.x86_64 : Nginx XSLT module
nginx-mod-mail.x86_64 : Nginx mail modules
nginx-mod-stream.x86_64 : Nginx stream modules

インストールしました。

$ dnf install nginx

Last metadata expiration check: 0:09:04 ago on Sat May 27 04:50:49 2023.
Dependencies resolved.
========================================================================================================
 Package                     Architecture   Version                           Repository           Size
========================================================================================================
Installing:
 nginx                       x86_64         1:1.22.1-1.amzn2023.0.3           amazonlinux          40 k
Installing dependencies:
 generic-logos-httpd         noarch         18.0.0-12.amzn2023.0.3            amazonlinux          19 k
 gperftools-libs             x86_64         2.9.1-1.amzn2023.0.2              amazonlinux         309 k
 libunwind                   x86_64         1.4.0-5.amzn2023.0.2              amazonlinux          66 k
 nginx-core                  x86_64         1:1.22.1-1.amzn2023.0.3           amazonlinux         583 k
 nginx-filesystem            noarch         1:1.22.1-1.amzn2023.0.3           amazonlinux          12 k
 nginx-mimetypes             noarch         2.1.49-3.amzn2023.0.3             amazonlinux          21 k

Transaction Summary
========================================================================================================
Install  7 Packages

完了です。

余談

dnf コマンドを実行しても通信が始まらず、困っていたのですが、
EC2をプライベートサブネットに配置しているのを忘れていただけでした。

プライベートサブネットで dnf を利用される場合は、
VPC にエンドポイントを追加する必要があるので、もしお困りの方はこちらも参考にしてください。

プライベートサブネット上の EC2 から dnf コマンドを実行できるようにする方法

  1. Amazon EC2 コンソールを開いてからインスタンスを選択します。
  2. [Networking] タブで、VPC ID とサブネット ID を書き留めます。
  3. Amazon VPC コンソールを開き、[Subnets] を選択し、[Subnet ID] を選択します。
  4. [Route Table] タブを選択し、Route Table ID を書き留めます。
  5. [Endpoints] を選択し、[Create Endpoint] を選択します。
  6. 次の情報を使用してゲートウェイエンドポイントを作成します。
    • us-east-1 にエンドポイントを作成する場合は、com.amazonaws.us-east-1.s3 を選択してください。他のリージョンにエンドポイントを作成する場合は、対応するリージョンコードを選択します。リージョンコードの全リストについては、「利用できるリージョン」を参照してください。
    • [VPC] で、自分のインスタンスの VPC ID を選択します。
    • [Configure route tables] で、インスタンスの [Route Table ID] を選択します。
  7. [Policy] で [Full Access] または [Custom] を選択します。
    • [Full Access] を選択した場合、エンドポイントポリシーで Amazon S3 へのフルアクセスを許可します。
    • [Custom] を選択した場合は、Amazon Linux リポジトリバケットで API 呼び出し s3:GetObject を許可する必要があります。

(引用元: https://repost.aws/ja/knowledge-center/ec2-al1-al2-update-yum-without-internet

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0