OpenSUSE 15.1にnginxをインストールする手順

OpenSUSE 15.1にnginxをインストールする手順

OpenSUSE 15.1にwebサーバー「nginx」をインストールするまでの手順を記述してます。

環境

  • OS OpenSUSE 15.1
  • nginx 1.16.1

nginxパッケージ検索

パッケージを検索してみます。

sudo zypper info nginx

<出力結果>
Loading repository data...
Reading installed packages...


Information for package nginx:
------------------------------
Repository     : openSUSE-Leap-15.1-Update
Name           : nginx
Version        : 1.16.1-lp151.4.11.1
Arch           : x86_64
Vendor         : openSUSE
Installed Size : 2.6 MiB
Installed      : No
Status         : not installed
Source package : nginx-1.16.1-lp151.4.11.1.src
Summary        : A HTTP server and IMAP/POP3 proxy server
Description    :
    nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev.
    It has been running on many heavily loaded Russian sites for more than two years.

nginxインストール

nginxのパッケージ情報が確認できたのでインストールします。

sudo zypper install nginx

<出力結果>
Continue? [y/n/v/...? shows all options] (y): y

nginx設定

自動起動と起動を設定します。

sudo systemctl enable --now nginx

ステータスを確認してみます。

sudo systemctl status nginx

<出力結果>
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since 
 Main PID: 2825 (nginx)
    Tasks: 2
   CGroup: /system.slice/nginx.service
           tq2825 nginx: master process /usr/sbin/nginx -g daemon off;
           mq2826 nginx: worker process

Jul 18 11:18:10 opensuse-leap-x64 systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jul 18 11:18:10 opensuse-leap-x64 nginx[2824]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jul 18 11:18:10 opensuse-leap-x64 nginx[2824]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jul 18 11:18:10 opensuse-leap-x64 systemd[1]: Started The nginx HTTP and reverse proxy server.

ポート80が開いていることも確認してみます。

sudo ss -tulpn | grep nginx

<出力結果>
tcp    LISTEN     0      128    0.0.0.0:80                 0.0.0.0:*                   users:(("nginx",pid=2826,fd=6),("nginx",pid=2825,fd=6))

適当なhtmlファイルをドキュメントルートに作成して動作確認してみます。

sudo vi /srv/www/htdocs/index.html

<編集>
<html>
 <head>
 <title>mebee</title>
 </head>
 <body>
 <h1>mebee nginx test</h1>
 <p>hello world</p>
 </body>
</html>

ブラウザから http://プライベートIP or サーバーアドレスにアクセスして、下図が表示されていれば正常に動作してます。

設定はファイルの場所「/etc/nginx/nginx.conf」に作成されてます。

sudo vi /etc/nginx/nginx.conf