OS | PageViews | 比率(%) |
---|---|---|
Windows | 7,165 | 73.2243 |
Mac OS | 1,598 | 16.3311 |
Linux | 427 | 4.3638 |
Android | 379 | 3.8733 |
Ubuntu Linux | 116 | 1.1855 |
unknown | 92 | 0.9402 |
FreeBSD | 4 | 0.0409 |
Fedora Linux | 3 | 0.0307 |
NetBSD | 1 | 0.0102 |
合 計 | 9,785 | 100.0000 |
OS | Version | PageViews | 比率(%) |
---|---|---|---|
Windows | 10 | 7,100 | 72.5600 |
Mac OS | X | 1,598 | 16.3311 |
Linux | unknown | 427 | 4.3638 |
Android | unknown | 379 | 3.8733 |
Ubuntu Linux | unknown | 116 | 1.1855 |
unknown | unknown | 92 | 0.9402 |
Windows | 7 | 39 | 0.3986 |
Windows | 8.1 | 21 | 0.2146 |
FreeBSD | unknown | 4 | 0.0409 |
Windows | 8 | 4 | 0.0409 |
Fedora Linux | unknown | 3 | 0.0307 |
NetBSD | unknown | 1 | 0.0102 |
Windows | XP | 1 | 0.0102 |
合 計 | 9,785 | 100.0000 |
ブラウザ | PageViews | 比率(%) |
---|---|---|
Chrome | 8,111 | 82.8922 |
Mozilla Firefox | 794 | 8.1145 |
Safari | 792 | 8.0940 |
Netscape Navigator | 82 | 0.8380 |
Internet Explorer | 3 | 0.0307 |
Mozilla SeaMonkey | 1 | 0.0102 |
unknown | 1 | 0.0102 |
Mozilla | 1 | 0.0102 |
合 計 | 9,785 | 100.0000 |
ブラウザ | Version | PageViews | 比率(%) |
---|---|---|---|
Chrome | 120.0.0.0 | 6,057 | 61.9009 |
Chrome | 118.0.0.0 | 1,060 | 10.8329 |
Safari | 604.1 | 567 | 5.7946 |
Chrome | 121.0.0.0 | 530 | 5.4165 |
Mozilla Firefox | 121.0 | 423 | 4.3229 |
Safari | 605.1.15 | 217 | 2.2177 |
Mozilla Firefox | 115.0 | 145 | 1.4819 |
Chrome | 119.0.0.0 | 144 | 1.4716 |
Netscape Navigator | 5.0 | 82 | 0.8380 |
Mozilla Firefox | 122.0 | 80 | 0.8176 |
Chrome | 109.0.0.0 | 44 | 0.4497 |
Mozilla Firefox | 102.0 | 27 | 0.2759 |
Chrome | 117.0.0.0 | 25 | 0.2555 |
Mozilla Firefox | 120.0 | 23 | 0.2351 |
Chrome | 116.0.0.0 | 23 | 0.2351 |
Mozilla Firefox | 119.0 | 22 | 0.2248 |
Chrome | 115.0.0.0 | 19 | 0.1942 |
Chrome | 99.0.4844.51 | 15 | 0.1533 |
Mozilla Firefox | 116.0 | 15 | 0.1533 |
Chrome | 112.0.0.0 | 14 | 0.1431 |
: | : | : | : |
合 計 | 9,785 | 100.0000 |
以上。
]]>旧年中はお世話になりました。 本年もどうぞよろしくお願いします。
話は変わりまして、先月12月分の当ブログアクセス状況を公開します。(※自分用の記録)
OS | PageViews | 比率(%) |
---|---|---|
Windows | 10,122 | 77.8496 |
Mac OS | 1,862 | 14.3209 |
Linux | 430 | 3.3072 |
Android | 310 | 2.3842 |
unknown | 162 | 1.2460 |
Ubuntu Linux | 113 | 0.8691 |
OpenBSD | 1 | 0.0077 |
FreeBSD | 1 | 0.0077 |
Fedora Linux | 1 | 0.0077 |
合 計 | 13,002 | 100.0000 |
OS | Version | PageViews | 比率(%) |
---|---|---|---|
Windows | 10 | 10,079 | 77.5188 |
Mac OS | X | 1,862 | 14.3209 |
Linux | unknown | 430 | 3.3072 |
Android | unknown | 310 | 2.3842 |
unknown | unknown | 162 | 1.2460 |
Ubuntu Linux | unknown | 113 | 0.8691 |
Windows | 7 | 25 | 0.1923 |
Windows | 8.1 | 10 | 0.0769 |
Windows | XP | 7 | 0.0538 |
OpenBSD | unknown | 1 | 0.0077 |
FreeBSD | unknown | 1 | 0.0077 |
Fedora Linux | unknown | 1 | 0.0077 |
Windows | Vista | 1 | 0.0077 |
合 計 | 13,002 | 100.0000 |
ブラウザ | PageViews | 比率(%) |
---|---|---|
Chrome | 10,983 | 84.4716 |
Safari | 989 | 7.6065 |
Mozilla Firefox | 865 | 6.6528 |
Netscape Navigator | 163 | 1.2537 |
Internet Explorer | 1 | 0.0077 |
unknown | 1 | 0.0077 |
合 計 | 13,002 | 100.0000 |
ブラウザ | Version | PageViews | 比率(%) |
---|---|---|---|
Chrome | 118.0.0.0 | 4,086 | 31.4259 |
Chrome | 120.0.0.0 | 3,995 | 30.7260 |
Chrome | 119.0.0.0 | 2,474 | 19.0278 |
Safari | 604.1 | 609 | 4.6839 |
Mozilla Firefox | 120.0 | 404 | 3.1072 |
Safari | 605.1.15 | 273 | 2.0997 |
Netscape Navigator | 5.0 | 163 | 1.2537 |
Mozilla Firefox | 115.0 | 154 | 1.1844 |
Mozilla Firefox | 121.0 | 137 | 1.0537 |
Safari | 538.1 | 85 | 0.6537 |
Chrome | 117.0.0.0 | 64 | 0.4922 |
Chrome | 116.0.0.0 | 59 | 0.4538 |
Mozilla Firefox | 119.0 | 49 | 0.3769 |
Chrome | 109.0.0.0 | 46 | 0.3538 |
Chrome | 114.0.0.0 | 33 | 0.2538 |
Mozilla Firefox | 102.0 | 24 | 0.1846 |
Chrome | 112.0.0.0 | 24 | 0.1846 |
Safari | 9537.53 | 21 | 0.1615 |
Chrome | 115.0.0.0 | 20 | 0.1538 |
Mozilla Firefox | 116.0 | 16 | 0.1231 |
: | : | : | : |
合 計 | 13,002 | 100.0000 |
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
openssl 未インストールならインストール。
# apt -y install openssl
秘密鍵生成。
# cd /etc/ssl/private
# openssl genrsa -des3 -out server.key 2048
Enter PEM pass phrase: # <= パスフレーズ設定
Verifying - Enter PEM pass phrase: # <= 確認再入力
秘密鍵からパスフレーズを削除。
# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key: # <= パスフレーズ
writing RSA key
# openssl req -new -days 3650 -key server.key -out server.csr
Ignoring -days without -x509; not generating a certificate
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP # <= 国の略名
State or Province Name (full name) [Some-State]:Shimane # <= 都道府県名
Locality Name (eg, city) []:Matsue # <= 市区町村名
Organization Name (eg, company) [Internet Widgits Pty Ltd]:var.com # <= サイト名(何でもよい)
Organizational Unit Name (eg, section) []: # <= 部署名(空でよい)
Common Name (e.g. server FQDN or YOUR name) []:www.var.com # <= ホスト名
Email Address []: webmaster@var.com # <= 管理者メールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: # <= 追加属性・空エンターでよい
An optional company name []: # <= 追加属性・空エンターでよい
# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Certificate request self-signature ok
subject=C = JP, ST = Shimane, L = Matsue, O = mk-mode.com, CN = www.mk-mode.com, emailAddress = webmaster@mk-mode.com
権限選定。
# chmod 400 server.*
以下のように、Nginx 設定ファイルを作成する。
(Nginx のインストール方法やバージョンによっては設定ファイルの構成が異なるので注意。以下は「Debian 12 (bookworm) - Web サーバ Nginx 構築(Nginx 公式リポジトリ使用)!」の方法でインストールした場合)
File: /etc/nginx/conf.d/ssl.conf
# HTTPS server
#
server {
listen 443 ssl;
server_name localhost;
#ssl_certificate cert.pem;
ssl_certificate /etc/ssl/private/server.crt;
#ssl_certificate_key cert.key;
ssl_certificate_key /etc/ssl/private/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
nginx -t
を実行する# systemctl restart nginx
ポート TCP:443 を開放する。
# ufw allow 443/tcp
Rule added
# ufw status
:
443/tcp ALLOW Anywhere
:
ブラウザから https://<サーバ名orIPアドレス>/
にアクセスし、セキュリティに関するページが表示されたら適宜インストールする。
ブラウザにより異なるが、Firefox なら「危険を理解した上で接続するには」をクリック後「例外追加」ボタンをクリックする。そして開いたウィンドウ内で「セキュリティ例外を追加」ボタンをクリックする。
認証に成功すると以下のように表示される。
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
$ sudo apt -y install curl gnupg2 ca-certificates lsb-release debian-archive-keyring
$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
$ gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
出力されるフィンガープリンが以下と一致することを確認する。
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>
$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/debian `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
$ echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
$ sudo apt -y update
$ sudo apt -y install nginx
Nginx がインストールできたか確認してみる。(-v
の代わりに -V
オプションを使用すると詳細に表示される)
$ sudo nginx -v
nginx version: nginx/1.24.0
今回のインストール環境の場合、基本的(グローバル)な設定のファイルは /etc/nginx/nginx.conf
で、このファイルから /etc/nginx/conf.d
ディレクトリ配下の設定ファイルを読み込む形式となっている。
取り急ぎ、デフォルトのままとした。
詳細な設定は、「当ブログ Nginx 関連の過去記事」を参照。
TCP ポート 80 を開放する必要がある。(HTTPS の場合は TCP: 443)
$ sudo ufw allow 80/tcp
Rule added
$ sudo ufw status
:
80/tcp ALLOW Anywhere
:
$ sudo systemctl start nginx
ブラウザで http://<サーバアドレス or ホスト名>/
にアクセスしてみる。
Welcome to nginx!
と以下5行くらい表示されば成功。
マシン起動時に自動で Nginx を起動させるには以下のようにする。(インストール直後は自動起動するようになっているはずなので、そうなっていない場合)
$ sudo systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
$ sudo systemctl is-enabled nginx
enabled
(nginx
はネイティブなサービスでないため、 systemd-sysv-install
にリダイレクトされる)
自動起動しないようにするには、
# systemctl disable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable nginx
Removed "/etc/systemd/system/multi-user.target.wants/nginx.service".
# systemctl is-enabled nginx
disabled
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
mysql
のキーワードが出現する。/var/lib/mysql
ディレクトリ配下とする。$ sudo apt -y install apt-transport-https curl
$ sudo mkdir -p /etc/apt/keyrings
$ sudo curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
File: /etc/apt/sources.list.d/mariadb.sources
# MariaDB 10.11 repository list - created 2023-10-27 02:05 UTC
# https://mariadb.org/download/
X-Repolib-Name: MariaDB
Types: deb
# deb.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# URIs: https://deb.mariadb.org/10.11/debian
URIs: https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/repo/10.11/debian
Suites: bookworm
Components: main
Signed-By: /etc/apt/keyrings/mariadb-keyring.pgp
$ sudo apt -y update
$ sudo apt -y install mariadb-server
$ sudo apt -y install mariadb-plugin-mroonga
$ sudo mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none): # <= root ユーザの既存パスワード: 空エンター
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] # <= Unix ソケット認証設定: Y 応答
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] # <= root パスワード変更: Y 応答
New password: # <= root パスワード
Re-enter new password: # <= root パスワード確認入力
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] # <= 匿名ユーザの削除: Y 応答
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n # <= root のリモートログイン: リモート接続したいので n 応答(Y でもよい)
... skipping.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] # <= テストデータベースの削除: Y 応答
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] # <= 特権情報のリロード: Y 応答
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
インストール直後は、サーバは起動している。
ログインしてみる。
$ mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 40
Server version: 10.11.5-MariaDB-1:10.11.5+maria~deb12 mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show engines;
+--------------------+---------+-------------------------------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+-------------------------------------------------------------------------------------------------+--------------+------+------------+
| CSV | YES | Stores tables as CSV files | NO | NO | NO |
| MRG_MyISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| Aria | YES | Crash-safe tables with MyISAM heritage. Used for internal temporary tables and privilege tables | NO | NO | NO |
| MyISAM | YES | Non-transactional engine with good performance and small data footprint | NO | NO | NO |
| SEQUENCE | YES | Generated tables filled with sequential values | YES | NO | YES |
| Mroonga | YES | CJK-ready fulltext search, column store | NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| InnoDB | DEFAULT | Supports transactions, row-level locking, foreign keys and encryption for tables | YES | YES | YES |
+--------------------+---------+-------------------------------------------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.000 sec)
MariaDB [(none)]> exit
Bye
mariadb -u root -p
は mysql -u root -p
でもよい。もし、全文検索エンジン Mroonga が前述の apt でのインストール方法でインストールされていなければ、 MariaDB コンソールで以下を実行してみる。
(MariaDB をインストールする過程で、なかなかうまくいかず色々とイジっているうちに、 apt インストールできない状態になるかもしれない(当方の経験談))
INSTALL SONAME 'ha_mroonga';
$ sudo systemctl start mariadb
$ sudo systemctl restart mariadb
$ sudo systemctl stop mariadb
$ systemctl status mariadb
$ systemctl is-enabled mariadb
mariadb
は mysqld
でもよい。必要に応じて、各種設定ファイルを編集する。(以下は、一例)
/etc/mysql/my.cnf
が /etc/mysql/conf.d
や /etc/mysql/mariadb.conf.d
ディレクトリ配下の cnf ファイルを読み込むようになっている。(以前のように /etc/my.cnf
ファイルにまとめて記述する方法にしてもよいだろう)
([mysqld]
の innodb_data_file_path
や innodb_log_file_size
を変更する際は、細心の注意を)
File: /etc/mysql/mariadb.conf.d/50-client.cnf
#
# This group is read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set = utf8mb4
# Example of client certificate usage
#ssl-cert=/etc/mysql/client-cert.pem
#ssl-key=/etc/mysql/client-key.pem
#
# Allow only TLS encrypted connections
#ssl-verify-server-cert=on
# This group is *never* read by mysql client library, though this
# /etc/mysql/mariadb.cnf.d/client.cnf file is not read by Oracle MySQL
# client anyway.
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
File: /etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#
[mysql]
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8mb4
no-auto-rehash
show-warnings
prompt=\u@\h:\d\_\R:\m:\\s>\_
pager="less -n -i -F -X -E"
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]
File: /etc/mysql/mariadb.conf.d/50-mysqld_safe.cnf
# NOTE: This file is read only by the traditional SysV init script, not systemd.
# MARIADB SYSTEMD DOES _NOT_ UTILIZE MYSQLD_SAFE NOR READ THIS FILE.
#
# For similar behaviour, systemd users should create the following file:
# /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
#
# To achieve the same result as the default 50-mysqld_safe.cnf, please create
# /etc/systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf
# with the following contents:
#
# [Service]
# User=mysql
# StandardOutput=syslog
# StandardError=syslog
# SyslogFacility=daemon
# SyslogLevel=err
# SyslogIdentifier=mysqld
#
# For more information, please read https://mariadb.com/kb/en/mariadb/systemd/
#
[mysqld_safe]
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# especially if they contain "#" chars...
socket = /var/run/mysqld/mysqld.sock
nice = 0
skip_log_error
syslog
File: /etc/mysql/mariadb.conf.d/50-server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
#
# Recovery
#
#innodb_force_recovery = 11 #クラッシュリカバリ時のみ有効化
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
lc_messages = en_US # Default: en_US
skip-external-locking
performance_schema = OFF # Default: ON
sql_mode = ''
default_storage_engine = InnoDB # Default: InnoDB
skip-character-set-client-handshake
# Broken reverse DNS slows down connections considerably and name resolve is
# safe to skip if there are no "host by domain name" access grants
#skip-name-resolve
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0 # 127.0.0.1
#
# * Fulltext Index
#
ft_min_word_len = 2
innodb_ft_min_token_size = 2
innodb_ft_enable_stopword = OFF
#
# * Fine Tuning
#
key_buffer_size = 8M # Default: 8M (for MyISAM)
myisam_sort_buffer_size = 8M # Default: 8M (for MyISAM)
sort_buffer_size = 8M # Default: 2M (通常時:8M, ALTER TABLE 時:64M)
read_buffer_size = 8M # Default: 128K
read_rnd_buffer_size = 8M # Default: 256K
join_buffer_size = 8M # Default: 128K
max_allowed_packet = 128M # Default: 1M
net_buffer_length = 1M # Default: 16K
thread_stack = 288K # Default: 192K(32bit), 288K(64bit)
thread_cache_size = 40 # Default: 0 (max_connections の 1/3 程度?)
table_open_cache = 400 # Default: 400 (同時接続数 * テーブル数?)
table_definition_cache = 400 # Default: -1:autosized = 400 + (table_open_cache / 2
tmp_table_size = 16M # Default: System 依存 (for Memory, <= max_heap_table_size)
max_heap_table_size = 32M # Default: 16M (for Memory, >= tmp_table_size)
bulk_insert_buffer_size = 64M
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam_recover_options = BACKUP
max_connections = 100 # Default: 151
max_connect_errors = 100 # Default: 100
max_user_connections = 0 # Default: 0
#table_cache = 64
#thread_concurrency = 10
wait_timeout = 300 # Default: 28800 (通常時:300, データインポート時:3600程度)
interactive_timeout = 3600 # Default: 28800
connect_timeout = 30 # Default: 10
net_read_timeout = 3600 # Default: 30
net_write_timeout = 3600 # Default: 60
#
# * Query Cache Configuration
#
query_cache_limit = 8M # Default: 1M
query_cache_size = 32M # Default: 0 (通常時: 32M, データインポート時: 0)
#
# * Logging and Replication
#
log_output = FILE # Default: FILE
log_warnings = 1 # Default: 1
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# Recommend only changing this at runtime for short testing periods if needed
#general_log_file = /var/log/mysql/mysql.log # デバッグ時に有効化
#general_log = 1 # デバッグ時に有効化
# When running under systemd, error logging goes via stdout/stderr to journald
# and when running legacy init error logging goes to syslog due to
# /etc/mysql/conf.d/mariadb.conf.d/50-mysqld_safe.cnf
# Enable this if you want to have error logging into a separate file
log_error = /var/log/mysql/error.log
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mariadb-slow.log # デバッグ時に有効>化
#slow_query_log = 1 # デバッグ時に有効>化
#long_query_time = 30 # 10 # デバッグ時に有効>化
#log_slow_verbosity = query_plan,explain
#log-queries-not-using-indexes
#min_examined_row_limit = 1000
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 101 # 1 # レプリケーション時 (1 〜 2^32 - 1)
#log_bin = mysql-bin # /var/log/mysql/mysql-bin.log # レプリケーション、ポイントインタイムリカバリを利用したい場合のみ有効化
expire_logs_days = 10
max_binlog_size = 100M
binlog_format = MIXED
log_bin_trust_function_creators = 1 # Default: 0 (for TRIGGER)
#binlog_do_db = include_database_name
#binlog_ignore_db = exclude_database_name
#
# * SSL/TLS
#
# For documentation, please read
# https://mariadb.com/kb/en/securing-connections-for-client-and-server/
#ssl-ca = /etc/mysql/cacert.pem
#ssl-cert = /etc/mysql/server-cert.pem
#ssl-key = /etc/mysql/server-key.pem
#require-secure-transport = on
#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
#
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
#
# * Event Scheduler
#
event_scheduler = 1 # Default: 0
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!
# Most important is to give InnoDB 80 % of the system RAM for buffer use:
# https://mariadb.com/kb/en/innodb-system-variables/#innodb_buffer_pool_size
#innodb_buffer_pool_size = 8G
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.11]
innodb_data_file_path = ibdata1:1G #:autoextend
innodb_autoextend_increment = 64 # Default: 64
innodb_file_per_table = 1
innodb_file_format = Barracuda # Default: Antelope
innodb_large_prefix = 1 # Default: 0
innodb_buffer_pool_size = 768M # Default: 128M (innodb_log_files_in_group * innodb_log_file_size < innodb_buffer_pool_size)
innodb_buffer_pool_instances = 16 # Default: autosized(32bit), 8(64bit) (innodb_buffer_pool_size >= 1G の場合にのみ有効)
innodb_sort_buffer_size = 8M # Default: 1M (通常時:8M, ALTER TABLE 時:256M)
innodb_thread_concurrency = 4 # Default: 0 (Defalut 推奨? CPU数 * ディスク数 * 2 が最適?)
innodb_thread_sleep_delay = 10000 # Default: 10000 (単位:マイクロ秒)
innodb_commit_concurrency = 4 # Default: 0 (Default 推奨?)
innodb_write_io_threads = 8 # Default: 4 (1 - 64)
innodb_read_io_threads = 8 # Default: 4 (1 - 64)
innodb_log_buffer_size = 32M # Default: 8M (通常時:32M, データインポート時:256M程度)
innodb_log_group_home_dir = /var/lib/mysql
innodb_log_files_in_group = 2 # Default: 2 (変更注意!)
innodb_log_file_size = 256M # Default: 48M (変更注意!)
# <= innodb_log_files_in_group innodb_log_file_size < innodb_buffer_pool_size
# [変更方法](http://dev.mysq.com/doc/refman/5.6/ja/innodb-data-log-reconfiguration.html)
innodb_max_dirty_pages_pct = 90 # Default: 75(%)
# <= 小さい値:低速&安定、大き 値:高速&不安定(?)
innodb_io_capacity = 256 # Default: 200 (100 - 2^64-1)
innodb_io_capacity_max = 512 # Default: 200 (100 - 2^64-1)
innodb_lru_scan_depth = 2048 # Default: 1024 (100 - 2^32-1(32bit))
innodb_flush_method = O_DIRECT # Default: Not set
innodb_flush_log_at_trx_commit = 1 # Default: 1 (データインポート時: 2 or 0)
innodb_doublewrite = 1 # Default: 1 (データインポート時: 0)
ibdata1
, ib_lofile0
, ib_logfile1
のサイズを変更した場合は、MariaDB サーバ停止後に ibdata1
, ib_lofile0
, ib_logfile1
を削除してから再度起動すること。インストール直後はマシン起動時に自動で MariaDB サーバが起動するようになっている。
自動起動しないようにしたければ以下のようにする。
$ sudo systemctl disable mariadb
Synchronizing state of mariadb.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable mariadb
Removed "/etc/systemd/system/multi-user.target.wants/mariadb.service".
$ systemctl is-enabled mariadb
disabled
mariadb
は mysqld
でもよい(mysql
はダメ)リモートで MariaDB サーバにアクセスする場合(GUI ツールを使用する場合等)は、TCP ポート 3306 を開放する必要がある。
$ sudo ufw allow 3306/tcp
Rule added
$ sudo ufw status
:
3306/tcp ALLOW Anywhere
:
以上。
]]>OS | PageViews | 比率(%) |
---|---|---|
Windows | 8,265 | 70.7499 |
Mac OS | 2,063 | 17.6596 |
Linux | 543 | 4.6482 |
Android | 472 | 4.0404 |
unknown | 203 | 1.7377 |
Ubuntu Linux | 128 | 1.0957 |
Fedora Linux | 3 | 0.0257 |
FreeBSD | 3 | 0.0257 |
Linux Mint | 1 | 0.0086 |
NetBSD | 1 | 0.0086 |
合 計 | 11,682 | 100.0000 |
OS | Version | PageViews | 比率(%) |
---|---|---|---|
Windows | 10 | 8,214 | 70.3133 |
Mac OS | X | 2,063 | 17.6596 |
Linux | unknown | 543 | 4.6482 |
Android | unknown | 472 | 4.0404 |
unknown | unknown | 203 | 1.7377 |
Ubuntu Linux | unknown | 128 | 1.0957 |
Windows | 7 | 42 | 0.3595 |
Windows | 8.1 | 8 | 0.0685 |
Fedora Linux | unknown | 3 | 0.0257 |
FreeBSD | unknown | 3 | 0.0257 |
Linux Mint | unknown | 1 | 0.0086 |
Windows | XP | 1 | 0.0086 |
NetBSD | unknown | 1 | 0.0086 |
合 計 | 11,682 | 100.0000 |
ブラウザ | PageViews | 比率(%) |
---|---|---|
Chrome | 9,589 | 82.0835 |
Safari | 1,056 | 9.0395 |
Mozilla Firefox | 878 | 7.5158 |
Netscape Navigator | 159 | 1.3611 |
合 計 | 11,682 | 100.0000 |
ブラウザ | Version | PageViews | 比率(%) |
---|---|---|---|
Chrome | 119.0.0.0 | 5,319 | 45.5316 |
Chrome | 118.0.0.0 | 2,157 | 18.4643 |
Chrome | 116.0.0.0 | 1,553 | 13.2940 |
Safari | 604.1 | 766 | 6.5571 |
Mozilla Firefox | 119.0 | 466 | 3.9890 |
Safari | 605.1.15 | 287 | 2.4568 |
Chrome | 117.0.0.0 | 186 | 1.5922 |
Netscape Navigator | 5.0 | 159 | 1.3611 |
Mozilla Firefox | 115.0 | 147 | 1.2583 |
Mozilla Firefox | 120.0 | 89 | 0.7619 |
Mozilla Firefox | 102.0 | 51 | 0.4366 |
Chrome | 114.0.0.0 | 45 | 0.3852 |
Chrome | 115.0.0.0 | 36 | 0.3082 |
Mozilla Firefox | 118.0 | 36 | 0.3082 |
Chrome | 109.0.0.0 | 35 | 0.2996 |
Chrome | 50.0.2661.102 | 26 | 0.2226 |
Mozilla Firefox | 116.0 | 24 | 0.2054 |
Chrome | 112.0.0.0 | 23 | 0.1969 |
Chrome | 111.0.0.0 | 16 | 0.1370 |
Chrome | 113.0.0.0 | 13 | 0.1113 |
: | : | : | : |
合 計 | 11,682 | 100.0000 |
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
# apt update
# apt install -y -V ca-certificates lsb-release wget
# wget https://apache.jfrog.io/artifactory/arrow/$(lsb_release --id --short | tr 'A-Z' 'a-z')/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
# apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb
# apt update
# wget https://packages.groonga.org/debian/groonga-apt-source-latest-$(lsb_release --codename --short).deb
# apt install -y -V ./groonga-apt-source-latest-$(lsb_release --codename --short).deb
# apt update
# apt install -y -V groonga
(トークナイザとして MeCab を使用しないのなら、この作業は不要)
# apt -y install mecab
(トークナイザとして MeCab を使用しないのなら、この作業は不要)
# apt install -y -V groonga-tokenizer-mecab
(トークンフィルタとして TokenFilterStem を使用しないのなら、この作業は不要)
# apt install -y -V groonga-token-filter-stem
(Munin プラグインを使用しないのなら、この作業は不要)
# apt install -y -V groonga-munin-plugins
(ノーマライザとして groonga-normalizer-mysql を使用しないのなら、この作業は不要)
# apt install -y -V groonga-normalizer-mysql
$ groonga --version
Groonga 13.0.8 [Linux,x86_64,utf8,match-escalation-threshold=0,nfkc,mecab,message-pack,mruby,onigmo,zlib,lz4,zstandard,epoll,rapidjson,apache-arrow,xxhash,blosc]
(過去記事「Linux Mint - Groonga インストール(by ソースビルド)!」を参照)
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
logrotate
)でメールログがローテーションされていることを想定。(デフォルトでなっているはず)Postfix のログ解析ツールである pflogsumm を、以下のようにしてインストールする。
# apt -y install pflogsumm
pflogsumm を実行するスクリプト pflogsumm_report
を以下のように作成する。
単純に pflogsumm
コマンドを実行するだけでもレポートはできるが、それだとログローテートしている場合に正常に取得できない部分も発生する可能性があるので、それを考慮している。
また、以下のスクリプトでは前日のメールログを解析し、結果を postmaster 宛にメール送信している。
File: pflogsumm_report
#!/bin/bash
LANG=C
MAILLOG='mktemp'
for log in `ls /var/log/mail.log*|sort -r`
do
cat $log >> $MAILLOG
done
REPORT=`mktemp`
pflogsumm --problems_first --verbose_msg_detail --mailq -d yesterday $MAILLOG > $REPORT
cat $REPORT | mail -s "`head -1 $REPORT` in `uname -n`" postmaster
rm -f $MAILLOG $REPORT
exit
スクリプト内のメール送信コマンド mail
が使用できない場合は、mailutils
or heirloom-mailx
or bsd-mailx
等をインストールする。複数ある場合は、update-alternatives --config mailx
でデフォルト設定をする。
なお、ログローテートしていない場合は、もっと簡単なスクリプトにすることも可能であるし、pflogsumm
コマンドを直接実行して運用してもよい。
# chmod 700 pflogsumm_report
作成したスクリプトを実行してみる。
(postfix の再起動が必要かも。これまで再起動は必要なかったが)
問題がなければ、 postmaster 宛にメールが送信されるはずである。
# ./pflogsumm_report
毎日自動で実行するように cron 登録する。
# mv pflogsumm_report /etc/cron.daily/
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
Postfix を ClamAV と連携させてウィルススキャンを行うのに必要な ClamAV daemon, amavisd-new を、以下のようにしてインストールする。
# apt -y install clamav-daemon amavisd-new
Postfix と ClamAV を連携するのに必要な amavisd-new の設定ファイルを用意し、編集する。
# cp /usr/share/doc/amavisd-new/examples/amavisd.conf-default /etc/amavis/amavisd.conf
File: /etc/amavis/amavisd.conf
$myhostname = 'mail.mk-mode.com'; # <= ホスト名
$mydomain = 'mk-mode.com'; # <= ドメイン名
$daemon_user = 'amavis'; # <= amavis デーモンユーザ名
$daemon_group = 'amavis'; # <= amavis デーモングループ名
$MYHOME = '/var/lib/amavis'; # <= amavisd ホーム
# $virus_admin = undef; # <= コメント化されていることを確認(ウィルス検知を都度通知しない)
File: /etc/amavis/conf.d/15-content_filter_mode
@bypass_virus_checks_maps = ( # <= コメント解除
\%bypass_virus_checks, \@bypass_virus_checks_acl, \$bypass_virus_checks_re); # <= コメント解除
@bypass_spam_checks_maps = ( # <= コメント解除
\%bypass_spam_checks, \@bypass_spam_checks_acl, \$bypass_spam_checks_re); # <= コメント解除
ちなみに、amavisd.conf
にも同じ記述がある。どちらを有効にしても良いだろう。
メールのウィルスチェックの度に clamscan が作動するとマシンが非力な場合は非常に重くなるため、 clamav-daemon が動作する今回の環境では clamdscan でウィルスチェックを行うこととする。(clamscan と clamdscan の違いについては、ここでは説明しない)
File: /etc/amavis/conf.d/15-av_scanners
#['ClamAV-clamscan', 'clamscan', # <= コメント化
['ClamAV-clamscan', 'clamdscan', # <= 追加
Considered UNSOLICITED BULK EMAIL, apparently from you
というタイトルのメールが届くことがあるので、それを抑止するための設定を行う。
File: /etc/amavis/conf.d/20-debian_defaults
#$final_banned_destiny = D_DISCARD;
$final_banned_destiny = D_REJECT;
D_PASS
… メールは受信者に配送されるD_REJECT
… メールは配送されないが、送信者に配送されなかった事を伝えるD_BOUNCE
… メールは配送されないが、送信者に配送されなかった事を伝える。例外で伝えない場合もあるD_DISCARD
… メールは配送されず、送信者にも配送されなかった事を伝えないFile: /etc/postfix/main.cf
# 最終行へ追加
content_filter=smtp-amavis:[127.0.0.1]:10024
File: /etc/postfix/master.cf
# 最終行へ追加
smtp-amavis unix - - n - 2 smtp
-o smtp_data_done_timeout=1200
-o smtp_send_xforward_command=yes
-o disable_dns_lookups=yes
127.0.0.1:10025 inet n - n - - smtpd
-o content_filter=
-o local_recipient_maps=
-o relay_recipient_maps=
-o smtpd_restriction_classes=
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o strict_rfc821_envelopes=yes
-o smtpd_error_sleep_time=0
-o smtpd_soft_error_limit=1001
-o smtpd_hard_error_limit=1000
処理に必要なファイルを作成したり、権限設定、ユーザ作成を行う。
# touch /etc/mailname
# chmod -R 775 /var/lib/amavis/tmp
# usermod -G amavis clamav
ClamAV daemon, Postfix, Amavisd を再起動する。
# systemctl restart clamav-daemon
# systemctl restart postfix
# systemctl restart amavis
デフォルトで自動起動する設定になっている。
# systemctl is-enabled clamav-daemon
enabled
disabled
になっていれば、設定する。
# systemctl enable clamav-daemon
メールを送信してみる。
# echo test | mail -s "TEST" root
受信メールのヘッダに X-Virus-Scanned: Debian amavis at
の文字列が存在することが確認できれば成功である。(メールソフトでヘッダを表示できる。または、サーバ内に届いたメールファイルを開いてみる)
メール送信コマンド mail
が使用できない場合は、 mailutils
or heirloom-mailx
or bsd-mailx
等をインストールする。複数ある場合は、update-alternatives --config mailx
でデフォルト設定をする。
Return-Path: <root@vbox.mk-mode.com>
X-Original-To: root@mk-mode.com
Delivered-To: root@mk-mode.com
Received: from localhost (localhost [127.0.0.1])
by mail.mk-mode.com (Postfix) with ESMTP id 3E2698B
for <root@mk-mode.com>; Mon, 16 Oct 2023 14:25:44 +0900 (JST)
X-Virus-Scanned: Debian amavis at vbox.mk-mode.com
Received: from mail.mk-mode.com ([127.0.0.1])
by localhost (vbox.mk-mode.com [127.0.0.1]) (amavis, port 10024) with ESMTP
id gHktjXQxFmZn for <root@mk-mode.com>; Mon, 16 Oct 2023 14:25:43 +0900 (JST)
Received: by mail.mk-mode.com (Postfix, from userid 0)
id BD0798A; Mon, 16 Oct 2023 14:25:43 +0900 (JST)
Subject: TEST
To: root@mk-mode.com
User-Agent: mail (GNU Mailutils 3.15)
Date: Mon, 16 Oct 2023 14:25:43 +0900
Message-Id: <20231016052543.BD0798A@mail.mk-mode.com>
From: root <root@vbox.mk-mode.com>
test
以上。
]]>以前古いバージョンでの作業時に残していた記録を参考に作業を行い、今回更新した作業記録を貼付する形式の内容となっています。
(当然ながら、興味がなければスルーしてください)
192.168.11.0/24
を想定。mk-mode.com
、サーバホスト名は vbox
を想定。apt -y install openssl
でよい)# cd /etc/ssl/private
# openssl genrsa -aes128 -out server.key 2048
Enter PEM pass phrase: # <= サーバ証明書用パスワード設定
Verifying - Enter PEM pass phrase: # <= サーバ証明書用パスワード確認入力
# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key: # <= サーバ証明書用パスワード応答
writing RSA key
# openssl req -new -days 3650 -key server.key -out server.csr
Ignoring -days without -x509; not generating a certificate
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:JP # <= 国の略名
State or Province Name (full name) [Some-State]:Shimane # <= 都道府県名
Locality Name (eg, city) []:Matsue # <= 市区町村名
Organization Name (eg, company) [Internet Widgits Pty Ltd]:mk-mode.com # <= サイト名(何でもよい)
Organizational Unit Name (eg, section) []: # <= 部署名(空でよい)
Common Name (e.g. server FQDN or YOUR name) []:mail.mk-mode.com # <= ホスト名
Email Address []:postmaster@mk-mode.com # <= 管理者メールアドレス
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: # <= 追加属性・空エンターでよい
An optional company name []: # <= 追加属性・空エンターでよい
# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Certificate request self-signature ok
subject=C = JP, ST = Shimane, L = Matsue, O = mk-mode.com, CN = mail.mk-mode.com, emailAddress = postmaster@mk-mode.com
# chmod 400 server.*
File: /etc/postfix/main.cf
# SSL 用(最終行に追加)
smtpd_use_tls = yes
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
smtpd_tls_cert_file = /etc/ssl/private/server.crt
smtpd_tls_key_file = /etc/ssl/private/server.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
File: /etc/postfix/master.cf
# コメント解除
submission inet n - y - - smtpd
-o syslog_name=postfix/submission
# -o smtpd_tls_security_level=encrypt
-o smtpd_sasl_auth_enable=yes
# 最終行に追記
smtps inet n - y - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
-o smtpd_sasl_auth_enable=yes
File: /etc/dovecot/conf.d/10-ssl.conf
# SSL 有効化
ssl = yes
# 証明書/鍵ファイル指定
ssl_cert = </etc/ssl/private/server.crt
ssl_key = </etc/ssl/private/server.key
# systemctl restart postfix dovecot
実際に運用する場合は、TCP ポート 465(SMTPS), 993(IMAPS), 995(POP3S) を開放する必要がある。
# ufw allow 465,993,995/tcp
Rule added
# ufw status
:
465,993,995/tcp ALLOW Anywhere
:
メールソフトではポート番号を変更すればよい。
993
(IMAP) or 995
(POP)465
認証警告画面が表示され、認証すれば(例外として承認すれば) SSL 通信で送受信できるようになる。
以上。
]]>