FreeBSDのインストールが終わり、これからサーバーの構築を始めますがコンソール画面では何かと作業がしにくいので、TeraTerm等を使用しWindowsから操作します。
OpenSSH サーバーはデフォルトでパスワード認証方式でのログインは可能となっています。
サービスが有効になっていればリモートログインすることができます。
sshd サービスの有効確認
1 2 |
# grep sshd /etc/rc.conf sshd_enable="YES" |
これでWindowsのTeraTermからSSH接続できます(TeraTermでの設定は他のOSの初期設定を参照してください)
1. バイナリーの更新
カーネルなどのバージョン情報の表示
1 2 |
# uname -srm FreeBSD 14.3-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 update2.freebsd.org... done. Fetching metadata signature for 14.3-RELEASE from update2.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 14.3-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 14.3-RELEASE amd64 |
1 2 3 4 |
# freebsd-version -kur 14.3-RELEASE 14.3-RELEASE 14.3-RELEASE |
2. Pkgng
2.1 パッケージシステム (pkgng) の初回実行設定
最新の状態にします。
1 2 3 4 5 6 7 8 9 10 |
# 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:14:amd64/quarterly, please wait… Verifying signature with trusted certificate pkg.freebsd.org.2013102301… done Installing pkg-2.1.2… Extracting pkg-2.1.2: 100% Updating FreeBSD repository catalogue… -------------------------------------- |
2.2 Pkgコマンド使用方法
1️⃣ アプリケーションの検索
例としてMysql8を探す場合
1 2 3 4 5 6 |
# pkg search mysql8 mysql-connector-odbc-unixodbc-mysql80-8.0.32 ODBC driver for MySQL80 / unixodbc mysql80-client-8.0.41 Multithreaded SQL database (client) mysql80-server-8.0.41 Multithreaded SQL database (server) mysql84-client-8.4.3_1 Multithreaded SQL database (client) mysql84-server-8.4.3_1 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.14.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.65.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.3 Unicode string library pkg-2.1.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 |
# pkg info curl curl-8.14.0 Name : curl Version : 8.14.0 Installed on : Fri Jun 13 18:37:15 2025 JST Origin : ftp/curl Architecture : FreeBSD:14:amd64 Prefix : /usr/local Categories : www net ftp Licenses : MIT Maintainer : sunpoet@FreeBSD.org WWW : https://curl.se/ Comment : Command line tool and library for transferring data with URLs --------------------------------------------------- |
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.14.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.65.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.3 Unicode string library pkg-2.1.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.14.0 > indexinfo-0.3.1_1 = libidn2-2.3.8 = liblz4-1.10.0,1 = libnghttp2-1.65.0 = libpsl-0.21.5_2 = libssh2-1.11.1,3 = libunistring-1.3 = pkg-2.1.2 = zstd-1.5.7 = |
>: 現在インストールされているものより新しいバージョンがリリースされている場合
=: 現在インストールされているものと同等のバージョンがリリースされている場合
<: 現在インストールされているものより古いバージョンがリリースされている場合
7️⃣ Packagesの更新
1 |
# pkg upgrade [バッケージ名] |
全てのパッケージを更新する場合
1 |
# pkg upgrade |
3 Ports Collectionのインストール
FreeBSD14ではportsnapが削除されていますのでgitを用いて,ポーツ・コレクション(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 40」が必要になりますので、アップグレードする
「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.40 |
perl5.36をアンインストール
1 |
# pkg remove -y perl5 |
1 2 3 |
# cd /usr/ports/lang/perl5.40 # make NO_DIALOG=yes # make reinstall |
gitが削除されているので再度インストールしておく
1 |
# pkg install git |
4️⃣ ports 用メンテナンスツール
「ports」をメンテナンスするための「ports」、「portupgrade」をインストールします。
1 2 3 4 5 6 7 |
# cd /usr/ports/ports-mgmt/portupgrade # make config オプションはデフォルト # make NO_DIALOG=yes # make reinstall |
5️⃣ INDEXの更新
1 2 3 |
# portsdb -Fu -F:INDEXファイル取得 -u:できたINDEXファイルを元にバイナリDBを更新 |
データベースの状態を参照するには
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# portversion -v [Reading data from pkg(8) ... - 68 packages found - done] autoconf-2.72 = up-to-date with port autoconf-switch-20220527 = up-to-date with port automake-1.17 = up-to-date with port brotli-1.1.0,1 = up-to-date with port bsddialog-1.0.4 = up-to-date with port curl-8.14.0 = up-to-date with port db5-5.3.28_9 = up-to-date with port expat-2.7.0 < needs updating (port has 2.7.1) gettext-runtime-0.23.1 = up-to-date with port gettext-tools-0.23.1_1 = up-to-date with port git-2.49.0 = up-to-date with port gmake-4.4.1 = up-to-date with port help2man-1.49.3_1 = up-to-date with port indexinfo-0.3.1_1 = up-to-date with port --------------------------------------------------- |
「=」マークがついていれば、最新版がインストールされている
「<」マークがついていれば、「ports」に新しい版が存在する
6️⃣ ports のアップグレード
上記で確認した結果、新しいバージョンが出ている「ports」を更新する
1 |
# portupgrade expat |