自分用メモなのでかなり割愛しています。詳細を知りたい場合は各々のサイトでご確認ください。
Fedora39 は最小パッケージでインストール メディアからのインストール手順は割愛します
メディアからのインストール後、再起動を実施した後に IPアドレスの設定画面が今までは表示されてましたが、 その後のバージョンではこのモードが表示されずログイン画面が表示されます。
そのため、ネットワーク設定のためのコマンドを使用して設定をします
xxxxxxxxxxnmcli connection ※アクティブになっているネットワークポートを確認nmcli connection modify ens3 ipv4.addresses 10.0.0.30/23 ※ens3 がアクティブと確認したので ens3 を設定nmcli connection modify ens3 ipv4.gateway 192.0.2.1nmcli connection modify ens3 ipv4.dns 1.1.1.1systemctl restart NetworkManager
※ ipv6 の設定も行わなければならないが、コンソールはコピー&ペーストができないため、 入力文字数が複雑な IPv6 の設定はターミナルエミュレータが接続できるようになってから行う
nmcli connection show ens3
コンソール画面上では操作がしづらいので、まず ssh が使える状態にしてからターミナルエミュレータで設定を行います
xxxxxxxxxx# This file controls the state of SELinux on the system.# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disabled ※enforcingをdisabledに変更# SELINUXTYPE= can take one of these three values:# targeted - Targeted processes are protected,# minimum - Modification of targeted policy. Only selected processes are protected.# mls - Multi Level Security protection.SELINUXTYPE=targeted設定後OSを再起動する。
sshの接続ポート番号を任意の番号に変更
xxxxxxxxxxPort 2222 ※22 から変更PermitRootLogin no ※Fedora31からデフォルトで no なので変更不要xxxxxxxxxxsystemctl restart sshdデフォルトは ssh のポートしか空いてないので、http のポートを開ける。
x
firewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --add-service=httpsfirewall-cmd --permanent --add-port=1234/tcpfirewall-cmd --reloadxxxxxxxxxxfirewall-cmd --staterunningxxxxxxxxxxfirewall-cmd --list-servicesdhcpv6-client ssh
ドメイン名接続の場合は IPv6 が優先されてしまうため、IPv4 のみが設定されている状態だと接続できない そのため、IPv4 の IP アドレスを直接入力して接続を行う
xnmcli connection ※アクティブになっているネットワークポートを確認nmcli connection modify ens3 ipv6.addresses 2401:2500:102:1212:133:242:205:108nmcli connection modify ens3 ipv6.gateway fe80::1nmcli connection modify ens3 ipv6.dns 2606:4700:4700::1111 ※クラウドフレアの IPv6 の DNSsystemctl restart NetworkManager
x
dnf install nginxdnf install php-pdo_mysql php php-gd php-mbstring php-fpm php-devel php-opcache php-pecl-apcu php-pecl-memcacheddnf install mariadb mariadb-serverdnf install postfix mailx ※PHPからメール送信に必要dnf install composer ※Laravelのアップデートdnf install htopx
systemctl enable nginxsystemctl start nginxsystemctl enable php-fpmsystemctl start php-fpmsystemctl enable mariadbsystemctl start mariadbsystemctl enable chronydsystemctl start chronydsystemctl enable postfixsystemctl start postfixxxxxxxxxxxpool 2.fedora.pool.ntp.org iburst※現在はディストリビュータ毎の pool サーバを指定することで、ラウンドロビンで ntp サーバを参照するので設定不要です。
xxxxxxxxxxchronyc sources
xxxxxxxxxxclient_max_body_size 2G;xxxxxxxxxxgzip on;gzip_http_version 1.0;gzip_vary on;gzip_comp_level 6;gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;gzip_disable "MSIE [1-6]\.";gzip_disable "Mozilla/4";gzip_proxied any;gzip_buffers 16 8k;xxxxxxxxxxcurl -I -H 'Accept-Encoding: gzip,deflate' http://www.qurataro.com/wikipedia/css/jqcloudlist.cssContent-Encoding: gzip が確認できたらOK
xxxxxxxxxxpost_max_size 2GBupload_max_filesize 2GBx
date.timezone = Asia/Tokyox
su - root ※ root ユーザーにならないと MariaDB の root ユーザーにアクセスできませんmysql -u rootmysql > SET PASSWORD = PASSWORD('youwantpassword')NetworkManager-wait-online はネットワークが正常に起動しているかを確認するデーモンですが、VPS環境のようにネットワークチェックに時間がかかる環境だとデフォルトの60秒では早すぎてエラーが出ます。そこで起動時間を240秒に変えることで回避することができます。
x
cp -p /usr/lib/systemd/system/NetworkManager-wait-online.service /etc/systemd/system/.vi /etc/systemd/system/NetworkManager-wait-online.servicex[Unit]Description=Network Manager Wait OnlineDocumentation=man:nm-online(1)Requires=NetworkManager.serviceAfter=NetworkManager.serviceBefore=network-online.target
[Service]Type=oneshotExecStart=/usr/bin/nm-online -s -qRemainAfterExit=yesEnvironment=NM_ONLINE_TIMEOUT=240 ←デフォルトは60
[Install]WantedBy=network-online.target無料の SSL 証明書を取得する方法です。
xxxxxxxxxx※CentOS8系のみ実施 dnf install epel-release dnf install certbot※このコマンドを動かすために必要な python ライブラリなども同時にダウンロードされる
xxxxxxxxxxcertbot certonly \ # 証明書の作成 --webroot \ # 既存のウェブサーバを使うモードを選択 -w /usr/share/nginx/html \ # ドキュメント・ルートのパス -d www.qurataro.com # 認証するドメイン名そのあと、規約の同意(Agree)
xxxxxxxxxxcertbot renew
xxxxxxxxxxls /etc/letsencrypt/accounts archive csr keys live renewal renewal-hooksxxxxxxxxxxls /etc/letsencrypt/live/qurataro.com/cert.pem chain.pem fullchain.pem privkey.pemxxxxxxxxxxserver { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; server_name qurataro.com; root /usr/share/nginx/html;
ssl_protocols TLSv1.2 TLSv1.3; ※ TLS 1.1以前は脆弱性があるため使用を1.2,1.3に限定する ssl_certificate "/etc/letsencrypt/live/qurataro.com/fullchain.pem"; ssl_certificate_key "/etc/letsencrypt/live/qurataro.com/privkey.pem"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers ECDHE+AESGCM:DHE+aRSA+AESGCM:ECDHE+AESCCM:DHE+aRSA+AESCCM:ECDHE+CHACHA20:DHE+aRSA+CHACHA20:+AES128:+DHE; ssl_prefer_server_ciphers on; ※CBC, GCMなどの古い暗号は脆弱性があるため新しい暗号に限定する
# Load configuration files for the default server block. include /etc/nginx/default.d/*.conf;
location / { }
error_page 404 /404.html; location = /40x.html { }
error_page 500 502 503 504 /50x.html; location = /50x.html { }}証明書の期限を定期的に自動更新する設定を入れます。
※cron は脆弱性の問題があり Fedora36 からデフォルトではインストールされない。そのため、cron の代替えである systemd の timer 機能を使用する。
x# systemctl list-timersNEXT LEFT LAST PASSED UNIT ACTIVATESThu 2022-06-02 05:54:20 JST 14h left Wed 2022-06-01 15:33:41 JST 13min ago certbot-renew.timer certbot-renew.service
上記コマンドで certbot-renew.timer が表示されたら設定されている証明になります。 certbot をインストールすると自動で設定される
もし、systemctl list-timers コマンドで certbot-renew.timer が設定されていない場合は手動で設定します
xsystemctl enable --now certbot-renew.timer
※インストールすると自動で設定されていることが多い
Let's Encrypt には証明書の更新をトリガーとして、処理を実行させる機能があります
xls /etc/letsencrypt/renewal-hooks/deploy post pre
目的に応じて以下のフォルダにスクリプトを入れることで実行させることができます
deploy 新規作成時 pre 前処理 post 後処理
以下のスクリプトを /etc/letsencrypt/renewal-hooks/post に配置する
x#/bin/bash# Restart Nginx/usr/bin/systemctl restart nginx# Create a certification key file that combines CERT and KEY for Cockpitcat /etc/letsencrypt/live/www.qurataro.com/fullchain.pem > /etc/cockpit/ws-certs.d/10-letsecnrypt.certcat /etc/letsencrypt/live/www.qurataro.com/privkey.pem >> /etc/cockpit/ws-certs.d/10-letsecnrypt.cert# Restart Cockpit/usr/bin/systemctl restart cockpit
xxxxxxxxxxtar xvfz mecab-x.xx.xx.tar.gz./configure --with-charset=utf8makemake installxxxxxxxxxx tar zxfv mecab-ipadic-2.7.0-XXXX.tar.gz mecab-ipadic-2.7.0-XXXX ./configure --with-charset=utf8 make make installwikipedia.dic を作成しているのでそれを利用するように修正する。 /usr/local/lib/mecab に作成した辞書やユーザ辞書を配置する。
xxxxxxxxxxdicdir = /usr/local/lib/mecab/dic/ipadicuserdic = /usr/local/lib/mecab/dic/ipadic/wikipedia.dicphp-mecab-0.5.0 は PHP7 系に未対応の為、PHP7系対応済みの php-mecab-0.6.0 を使用する。
xxxxxxxxxxwget https://github.com/rsky/php-mecab/archive/master.ziptar xzvf master.zipcd php-mecab-master/mecabphpize./configure --with-php-config=/bin/php-config --with-mecab=/usr/local/bin/mecab-configmakemake installxxxxxxxxxxvi /etc/php.d/mecab.iniextension=mecab.so/usr/local/libexec/mecab/mecab-dict-index -d /usr/local/lib/mecab/dic/ipadic -u wikipedia.dic -f utf-8 -t utf-8 wikipedia.csv