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?

nginx をインストール ( Ubuntu 24.04 )

Last updated at Posted at 2025-10-09

Overview

Install nginx to ubuntu 24.04

依存関係のインストール

.bash
sudo apt update
sudo apt install gnupg2 ca-certificates lsb-release ubuntu-keyring

署名キーをパッケージ認証のために取得

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

.bash
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:

.bash
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:

.bash
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

nginx の安定版リポジトリをセットアップ

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

.bash
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:

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

nginx をインストール

.bash
sudo apt update
sudo apt install nginx
.bash
nginx -v
nginx version: nginx/1.28.0

sudo systemctl status nginx
[sudo] password for username: 
○ nginx.service - nginx - high performance web server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en>
     Active: inactive (dead)
       Docs: https://nginx.org/en/docs/

sudo systemctl start nginx

sudo systemctl status nginx
● nginx.service - nginx - high performance web server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: en>
     Active: active (running) since Fri 2025-10-10 10:20:36 JST; 4s ago
     ......
     ...

参考

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?