FreeBSDのインストールが終わり、これからサーバーの構築を始めますがコンソール画面では何かと作業がしにくいので、Tabby Terminal等を使用しWindowsからリモート接続します。
OpenSSH サーバーはデフォルトでパスワード認証方式でのログインは可能となっています。
サービスが有効になっていればリモートログインすることができます。
sshd サービスの有効確認
|
1 2 |
# grep sshd /etc/rc.conf sshd_enable="YES" |
これでWindowsのTabby TerminalからSSH接続できます
1. バイナリーの更新
カーネルなどのバージョン情報の表示
|
1 2 |
# uname -srm FreeBSD 15.0-RELEASE amd64 |
利用可能なすべてのバイナリ更新(セキュリティアップデート)を取得
今回はアップデートがありませんでした
|
1 2 3 4 5 6 7 8 9 10 |
# freebsd-update fetch Looking up update.FreeBSD.org mirrors... 3 mirrors found. Fetching public key from update1.freebsd.org... done. Fetching metadata signature for 15.0-RELEASE from update1.freebsd.org... done. Fetching metadata index... done. Fetching 1 metadata files... done. Inspecting system... done. Preparing to download files... done. No updates needed to update system to 15.0-RELEASE-p0. |
更新またはアップグレードをインストール
|
1 2 3 |
# freebsd-update install No updates are available to install. Run 'freebsd-update [options] fetch' first. |
インストールしたイメージで起動するようにサーバーを再起動
|
1 |
# shutdown -r now |
更新後のバージョンを確認
|
1 2 |
# uname -srm FreeBSD 15.0-RELEASE amd64 |
|
1 2 3 4 |
# freebsd-version -kur 15.0-RELEASE 15.0-RELEASE 15.0-RELEASE |
2. Pkgng
2.1 パッケージシステム (pkgng) の初回実行設定
最新の状態にします。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# pkg update The package management tool is not yet installed on your system. Do you want to fetch and install it now? [y/N]: y Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/quarterly, please wait... Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done Installing pkg-2.4.2... Extracting pkg-2.4.2: 100% Updating FreeBSD-ports repository catalogue... Fetching meta.conf: 100% 179 B 0.2kB/s 00:01 Fetching data.pkg: 100% 10 MiB 10.7MB/s 00:01 Processing entries: 100% FreeBSD-ports repository update completed. 36512 packages processed. Updating FreeBSD-ports-kmods repository catalogue... Fetching meta.conf: 100% 179 B 0.2kB/s 00:01 Fetching data.pkg: 100% 31 KiB 31.6kB/s 00:01 Processing entries: 100% FreeBSD-ports-kmods repository update completed. 207 packages processed. All repositories are up to date. |
2.2 Pkgコマンド使用方法
1️⃣ アプリケーションの検索
例としてMysql8を探す場合
|
1 2 3 4 5 |
# pkg search mysql8 mysql80-client-8.0.43 Multithreaded SQL database (client) mysql80-server-8.0.43 Multithreaded SQL database (server) mysql84-client-8.4.5 Multithreaded SQL database (client) mysql84-server-8.4.5 Multithreaded SQL database (server) |
2️⃣ アプリケーションをインストール
例としてcurl をインストールする
|
1 |
# pkg install curl |
3️⃣ インストールされているパッケージに関する情報の取得
|
1 2 3 4 5 6 7 8 9 10 11 12 |
# pkg info brotli-1.1.0,1 Generic-purpose lossless compression algorithm curl-8.16.0 Command line tool and library for transferring data with URLs indexinfo-0.3.1_1 Utility to regenerate the GNU info page index libidn2-2.3.8 Implementation of IDNA2008 internationalized domain names liblz4-1.10.0,1 LZ4 compression library, lossless and very fast libnghttp2-1.67.0 HTTP/2 C Library libpsl-0.21.5_2 C library to handle the Public Suffix List libssh2-1.11.1,3 Library implementing the SSH2 protocol libunistring-1.4.1 Unicode string library pkg-2.4.2 Package manager zstd-1.5.7 Fast real-time compression algorithm |
先ほどインストールしたcurlの情報を取得するには
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# pkg info curl curl-8.16.0 Name : curl Version : 8.16.0 Installed on : Thu Dec 4 19:02:40 2025 JST Origin : ftp/curl Architecture : FreeBSD:15:amd64 Prefix : /usr/local Categories : ftp net www Licenses : MIT Maintainer : sunpoet@FreeBSD.org WWW : https://curl.se/ Comment : Command line tool and library for transferring data with URLs ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ It supports DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more. |
4️⃣ アプリケーションの削除
|
1 |
# pkg delete [パッケージ名] |
5️⃣ アプリケーションの状態
|
1 2 3 4 5 6 7 8 9 10 11 12 |
# pkg info brotli-1.1.0,1 Generic-purpose lossless compression algorithm curl-8.16.0 Command line tool and library for transferring data with URLs indexinfo-0.3.1_1 Utility to regenerate the GNU info page index libidn2-2.3.8 Implementation of IDNA2008 internationalized domain names liblz4-1.10.0,1 LZ4 compression library, lossless and very fast libnghttp2-1.67.0 HTTP/2 C Library libpsl-0.21.5_2 C library to handle the Public Suffix List libssh2-1.11.1,3 Library implementing the SSH2 protocol libunistring-1.4.1 Unicode string library pkg-2.4.2 Package manager zstd-1.5.7 Fast real-time compression algorithm |
6️⃣ アプリケーションの更新状態を参照
|
1 2 3 4 5 6 7 8 9 10 11 12 |
# pkg version brotli-1.1.0,1 = curl-8.16.0 = indexinfo-0.3.1_1 = libidn2-2.3.8 = liblz4-1.10.0,1 = libnghttp2-1.67.0 = libpsl-0.21.5_2 = libssh2-1.11.1,3 = libunistring-1.4.1 = pkg-2.4.2 = zstd-1.5.7 = |
>: 現在インストールされているものより新しいバージョンがリリースされている場合
=: 現在インストールされているものと同等のバージョンがリリースされている場合
<: 現在インストールされているものより古いバージョンがリリースされている場合
7️⃣ Packagesの更新
|
1 |
# pkg upgrade [バッケージ名] |
全てのパッケージを更新する場合
|
1 |
# pkg upgrade |
3 Ports Collectionのインストール
1️⃣ gitをインストールする
portsからインストールする場合
|
1 2 |
# cd /usr/ports/devel/git # make install clean |
pkgでインストールする場合
|
1 |
# pkg install git |
2️⃣ Port Collectionのインストール
portsツリーのHEADブランチのコピーをチェックアウトする
すでにPort Collectionがある場合は削除しておく
|
1 |
# rm -Rf /usr/ports |
|
1 |
# git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports |
/usr/portsを更新する
|
1 |
# git -C /usr/ports pull |
3️⃣ perl5 アップグレード
「perl5 42」が必要になりますので、アップグレードする
「make」のコンフィグレーションファイルを、コピーして編集する
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# cp /usr/share/examples/etc/make.conf /etc/make.conf # chmod 644 /etc/make.conf # vi /etc/make.conf X11を使用しない場合、下記を追加 OPTIONS_UNSET+=X11 OPTIONS_UNSET+=GUI NO_X=true PHPをインストールし、日本語を使用する場合下記を追加 OPTIONS_SET+=MBSTRING python3.11の系列をメインに使用する場合下記を記述 DEFAULT_VERSIONS+=python=3.11 python3=3.11 ruby3.2の系列をメインに使用する場合は下記を記述 DEFAULT_VERSIONS+=ruby=3.2 autoconfをインストールする際、「perl5 5.40」が必要になるので、あらかじめ記述する DEFAULT_VERSIONS+=perl5=5.42 |
|
1 2 3 |
# cd /usr/ports/lang/perl5.42 # make NO_DIALOG=yes # make reinstall |
gitが削除されているので再度インストールしておく
|
1 |
# pkg install git |
4️⃣ ports 用メンテナンスツール
「ports」をメンテナンスするための「ports」、「portupgrade」をインストールします。
|
1 |
# pkg install ports-mgmt/portupgrade |
5️⃣ アップグレードを開始する前に、/usr/ports/UPDATINGファイルを読んで、重要な変更点や手動での作業が必要な項目がないか確認する
|
1 |
# less /usr/ports/UPDATING |
6 .ポートを一括アップグレード
|
1 |
# portupgrade -aR |
個別にアップグレードの確認を行いたい場合は、-iオプションを追加します。
|
1 |
# portupgrade -aRi |
