0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

amazon linux 2023 Nginxのインストール

Posted at

Amazon Linux 2023でNginxをインストールする

Amazon linux 2023を触る機会があったので備忘録として。

まずはSSHでサーバーに接続する。

uname -r

6.1.41-63.114.amzn2023.x86_64

Nginxをインストール

dnf update
dnf -y install nginx

yumでもaptgetでもなくdnfを使う。

nginx -v
nginx version: nginx/1.24.0

再起動しても自動で起動するように設定

systemctl enable nginx

Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.

起動する

systemctl start nginx.service
systemctl status nginx.service
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
     Active: active (running) since Sun 2023-09-03 14:11:18 UTC; 7s ago
    Process: 26194 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Process: 26197 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 26203 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 26216 (nginx)
      Tasks: 2 (limit: 1114)
     Memory: 2.2M
        CPU: 56ms
     CGroup: /system.slice/nginx.service
             ├─26216 "nginx: master process /usr/sbin/nginx"
             └─26217 "nginx: worker process"

Sep 03 14:11:18 ip-xx-xx-xx-xx.ap-northeast-1.compute.internal systemd[1]: Starting nginx.service - The nginx HTTP and reverse proxy server...
Sep 03 14:11:18 ip-xx-xx-xx-xx.ap-northeast-1.compute.internal nginx[26197]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Sep 03 14:11:18 ip-xx-xx-xx-xx.ap-northeast-1.compute.internal nginx[26197]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Sep 03 14:11:18 ip-xx-xx-xx-xx.ap-northeast-1.compute.internal systemd[1]: Started nginx.service - The nginx HTTP and reverse proxy server.

ブラウザから確認するために、SSHの設定を少し修正

Host my-nginx
    Hostname xxx.xxx.xxx.xxx
    Port 22
    User ec2-user
    ServerAliveInterval 180
    ServerAliveCountMax 120
    IdentityFile ~/.ssh/xxxxxx.pem
    LocalForward 10000 localhost:80

ポート転送でlocalhost:10000ポートにアクセスした場合に、SSHアクセス先のlocalhost:80に転送するように設定

ブラウザのアドレスバーに「localhost:10000」を入力してエンターキーを押す
image.png

以上。

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?