ZFWordPress™

CentOS Linux 8 EOL の始まり…

1392 views
It takes about 7 minute(s) to read this content.

昨年末 CentOS Linux 8 の EOL の変更(2029/05 >> 2021/12)が発表された、現在自分の管理下にある CentOS 8 は3基… そろそろ手をつけないといかんなと、ついに重い腰を上げた ^^;

元来 CentOS 7 を 8 へ順当にアップグレード・委譲していくつもりでいたのだが CentOS の方針の変更により再考をせざるを得ない状況に追い込まれた感じです (T_T)

To-Do

  1. 現在稼働中の CentOS Linux 8 の後継 OS の選定
  2. 今年中に CentOS Linux 8 を後継 OS に引継ぐ
  3. 2022年中に最終的な方針を固め、CentOS 7 の EOL までに後継 OS への移行を完了、可能な限りライフサイクルが長い単一 OS が望ましい。

まずは移行先 OS の選定を始めようとアレやコレやとググってみるも特に決定打は見つけられず、手始めに CentOS Stream 8 のテスト環境を VPS で構築してみる、CentOS Stream 8 の構築・運用に関する覚書を記していこう。

CentOS Stream 8

OS インストール

Conoha のイメージを使用したので、ポチッとするとインストール完了。

Setup Stream 8

Firewall

何はともあれ Firewall を設定、IPアドレスで制限してパブリックは http と https のみ許可、自社IPからのアクセスを許可、SSHの接続許可を削除。

firewall-cmd --zone=trusted --add-source=XXXX:XXXX:XXXX:XXXX::/56 --permanent #IPv6
firewall-cmd --zone=trusted --add-source=XXX.XXX.XXX.XXX --permanent # IPv4
firewall-cmd --remove-service=ssh --zone=public --permanent
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
firewall-cmd --reload

Host name の設定

FQDN は設定しておいたほうが何かと便利。

hostnamectl set-hostname your.host.name

HTTP Server Settings

NGiNX

下記内容でファイルを作成し /etc/nginx/conf.d にホスト名.conf として保存、Let’s Encrypt での証明書取得時は HTTP ポートでアクセス可能な設定をしておく、 一度取得してしまえば HTTPS ポートで更新される。(証明書取得前は下記設定では NGINX のチェックを通らないので HTTP ポートのみの設定にしておく)

## 証明書取得時はコメントアウト
server {
    listen [::]:80;
    listen 80;
    server_name your.host.name www.host.name;
    return 301 https://your.host.name$request_uri;
}

## 証明書取得時はコメントアウト、URLの正規化等不要な場合はなくても良い。
# server {
#     listen 443;
#     server_name your.host.name;
#     ssl_certificate     /etc/letsencrypt/live/www.host.name/fullchain.pem;
#     ssl_certificate_key /etc/letsencrypt/live/www.host.name/privkey.pem;
#     return 301 https://your.host.name$request_uri;
# }

## 証明書取得時は listen ポートは 80 のみを通しSSL関連の設定はコメントアウトしておく
server {
    listen       [::]:443 ssl http2;
    listen       443 ssl http2;
    # listen       80;
    # listen       [::]:80;

    server_name  your.host.name;

    charset utf8;
    access_log  /var/www/your.host.name/log/host.access.log  main;

    client_max_body_size 64m;

    #ssl on;
    ssl_certificate     /etc/letsencrypt/live/your.host.name/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your.host.name/privkey.pem;

    # add_header Strict-Transport-Security 'max-age=31536000';

    location / {
        root   /var/www/your.host.name/html;
        index  index.html index.htm index.php;
        # try_files $uri $uri/ /$uri.php;
        try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/your.host.name/html;
        # fastcgi_pass   127.0.0.1:9000;
        fastcgi_pass   unix:/var/run/php-fpm/www.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        # fastcgi_param  PATH_INFO $fastcgi_script_name;    
        # fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }
}

PHP-FPM

www.conf ファイルの編集、user・group・listen の設定を確認しておく。

user = nginx
group = nginx

listen = /run/php-fpm/www.sock
;listen = 127.0.0.1:9000

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Let’s Encrypt CERTBOT

dnf --enablerepo=epel -y install snapd 
ln -s /var/lib/snapd/snap /snap
echo 'export PATH=$PATH:/var/lib/snapd/snap/bin' > /etc/profile.d/snap.sh
systemctl enable --now snapd.service snapd.socket 
snap install certbot --classic
certbot certonly --webroot -w /var/www/your.site.name/html -d your.site.name -d www.site.name -v

SNAP パッケージマネージャを使用すると、証明書が自動更新されるため更新設定が不要になる、certbot コマンドで証明書を発行する場合 “-d” オプションを複数記述すれば、一度に取得できる。 

About The Author

ufo

Comments

No commented yet.

Share on FacebookShare on TwitterShare on Pinterest