自分用メモなのでかなり割愛しています。詳細を知りたい場合は各々のサイトでご確認ください。
Fedora39 は最小パッケージでインストール メディアからのインストール手順は割愛します
メディアからのインストール後、再起動を実施した後に IPアドレスの設定画面が今までは表示されてましたが、 その後のバージョンではこのモードが表示されずログイン画面が表示されます。
そのため、ネットワーク設定のためのコマンドを使用して設定をします
xxxxxxxxxx
nmcli connection ※アクティブになっているネットワークポートを確認
nmcli connection modify ens3 ipv4.addresses 10.0.0.30/23 ※ens3 がアクティブと確認したので ens3 を設定
nmcli connection modify ens3 ipv4.gateway 192.0.2.1
nmcli connection modify ens3 ipv4.dns 1.1.1.1
systemctl 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の接続ポート番号を任意の番号に変更
xxxxxxxxxx
Port 2222 ※22 から変更
PermitRootLogin no ※Fedora31からデフォルトで no なので変更不要
xxxxxxxxxx
systemctl restart sshd
デフォルトは ssh のポートしか空いてないので、http のポートを開ける。
x
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=1234/tcp
firewall-cmd --reload
xxxxxxxxxx
firewall-cmd --state
running
xxxxxxxxxx
firewall-cmd --list-services
dhcpv6-client ssh
ドメイン名接続の場合は IPv6 が優先されてしまうため、IPv4 のみが設定されている状態だと接続できない そのため、IPv4 の IP アドレスを直接入力して接続を行う
xnmcli connection ※アクティブになっているネットワークポートを確認
nmcli connection modify ens3 ipv6.addresses 2401:2500:102:1212:133:242:205:108
nmcli connection modify ens3 ipv6.gateway fe80::1
nmcli connection modify ens3 ipv6.dns 2606:4700:4700::1111 ※クラウドフレアの IPv6 の DNS
systemctl restart NetworkManager
x
dnf install nginx
dnf install php-pdo_mysql php php-gd php-mbstring php-fpm php-devel php-opcache php-pecl-apcu php-pecl-memcached
dnf install mariadb mariadb-server
dnf install postfix mailx ※PHPからメール送信に必要
dnf install composer ※Laravelのアップデート
dnf install htop
x
systemctl enable nginx
systemctl start nginx
systemctl enable php-fpm
systemctl start php-fpm
systemctl enable mariadb
systemctl start mariadb
systemctl enable chronyd
systemctl start chronyd
systemctl enable postfix
systemctl start postfix
xxxxxxxxxx
pool 2.fedora.pool.ntp.org iburst
※現在はディストリビュータ毎の pool サーバを指定することで、ラウンドロビンで ntp サーバを参照するので設定不要です。
xxxxxxxxxx
chronyc sources
xxxxxxxxxx
client_max_body_size 2G;
xxxxxxxxxx
gzip 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;
xxxxxxxxxx
curl -I -H 'Accept-Encoding: gzip,deflate' http://www.qurataro.com/wikipedia/css/jqcloudlist.css
Content-Encoding: gzip が確認できたらOK
xxxxxxxxxx
post_max_size 2GB
upload_max_filesize 2GB
x
date.timezone = Asia/Tokyo
x
su - root ※ root ユーザーにならないと MariaDB の root ユーザーにアクセスできません
mysql -u root
mysql > 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.service
x[Unit]
Description=Network Manager Wait Online
Documentation=man:nm-online(1)
Requires=NetworkManager.service
After=NetworkManager.service
Before=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/nm-online -s -q
RemainAfterExit=yes
Environment=NM_ONLINE_TIMEOUT=240 ←デフォルトは60
[Install]
WantedBy=network-online.target
無料の SSL 証明書を取得する方法です。
xxxxxxxxxx
※CentOS8系のみ実施 dnf install epel-release
dnf install certbot
※このコマンドを動かすために必要な python ライブラリなども同時にダウンロードされる
xxxxxxxxxx
certbot certonly \ # 証明書の作成
--webroot \ # 既存のウェブサーバを使うモードを選択
-w /usr/share/nginx/html \ # ドキュメント・ルートのパス
-d www.qurataro.com # 認証するドメイン名
そのあと、規約の同意(Agree)
xxxxxxxxxx
certbot renew
xxxxxxxxxx
ls /etc/letsencrypt/
accounts archive csr keys live renewal renewal-hooks
xxxxxxxxxx
ls /etc/letsencrypt/live/qurataro.com/
cert.pem chain.pem fullchain.pem privkey.pem
xxxxxxxxxx
server {
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-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
Thu 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 Cockpit
cat /etc/letsencrypt/live/www.qurataro.com/fullchain.pem > /etc/cockpit/ws-certs.d/10-letsecnrypt.cert
cat /etc/letsencrypt/live/www.qurataro.com/privkey.pem >> /etc/cockpit/ws-certs.d/10-letsecnrypt.cert
# Restart Cockpit
/usr/bin/systemctl restart cockpit
xxxxxxxxxx
tar xvfz mecab-x.xx.xx.tar.gz
./configure --with-charset=utf8
make
make install
xxxxxxxxxx
tar zxfv mecab-ipadic-2.7.0-XXXX.tar.gz
mecab-ipadic-2.7.0-XXXX
./configure --with-charset=utf8
make
make install
wikipedia.dic を作成しているのでそれを利用するように修正する。 /usr/local/lib/mecab に作成した辞書やユーザ辞書を配置する。
xxxxxxxxxx
dicdir = /usr/local/lib/mecab/dic/ipadic
userdic = /usr/local/lib/mecab/dic/ipadic/wikipedia.dic
php-mecab-0.5.0 は PHP7 系に未対応の為、PHP7系対応済みの php-mecab-0.6.0 を使用する。
xxxxxxxxxx
wget https://github.com/rsky/php-mecab/archive/master.zip
tar xzvf master.zip
cd php-mecab-master/mecab
phpize
./configure --with-php-config=/bin/php-config --with-mecab=/usr/local/bin/mecab-config
make
make install
xxxxxxxxxx
vi /etc/php.d/mecab.ini
extension=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