FreeBSDとは
FreeBSD(フリービーエスディー)は、UNIXライクなオープンソースのOSソフトウェア。特にネットワークOSとしての稼動実績はLinux系を上回り、高い負荷にも安定したパフォーマンスを維持します。
FreeBSD(フリービーエスディー)は実用性を重視し堅牢で頑丈な設計を施されている点から、大手企業・サービスのFTP、WWW、電子メールサーバなどの運用に適しています。
今回は2026 年 9 月 8 日にリリースされたFreeBSD14.5をインストールし、サーバーの構築を行います。
インストール
1.インストールイメージのダウンロード
FreeBSD の配布サイト(https://download.freebsd.org/releases/ISO-IMAGES/14.5/) にアクセスし,
"FreeBSD-14.5-RELEASE-amd64-dvd1.iso"をダウンロードする
2.ブートディスクの作成
ダウンロードしたFreeBSD-14.5-RELEASE-amd64-dvd1.isoからブートディスクを作成する(DVDディスク)
USBメモリーに作成する場合はFreeBSD-14.5-RELEASE-amd64-memstick.imgをダウンロードしてWin32 Disk Imager等Image Writerを利用し、作成する
3.BIOS設定を変更し、作成したブートメディアから起動する
以降、インストールはFreeBSD-14.3と同様ですので割愛します。
初期設定
FreeBSDのインストールが終わり、これからサーバーの構築を始めますがコンソール画面では何かと作業がしにくいので、TeraTerm等を使用しWindowsから操作します。
OpenSSH サーバーはデフォルトでパスワード認証方式でのログインは可能となっています。
サービスが有効になっていればリモートログインすることができます。
sshd サービスの有効確認
# grep sshd /etc/rc.conf
sshd_enable="YES"
これでWindowsのTeraTermからSSH接続できます(TeraTermでの設定は他のOSの初期設定を参照してください)
2. システムの最新化
2.1 パッケージシステム (pkgng) の初回実行設定
最新の状態にします。
# pkg update
# pkg upgrade -y
カーネルを含むベースシステムを最新の状態に更新する場合
# freebsd-update fetch
Looking up update.FreeBSD.org mirrors... 3 mirrors found.
Fetching public key from update1.freebsd.org... done.
Fetching metadata signature for 14.5-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 14.5-RELEASE-p0.
2.2 Pkgコマンド使用方法
1.アプリケーションの検索
例としてMysql8を探す場合
# pkg search mysql8
mysql80-client-8.0.46 Multithreaded SQL database (client)
mysql80-server-8.0.46 Multithreaded SQL database (server)
mysql84-client-8.4.11 Multithreaded SQL database (client)
mysql84-server-8.4.11 Multithreaded SQL database (server)
2.アプリケーションをインストール
例としてcurl をインストールする
# pkg install curl
3.インストールされているパッケージに関する情報の取得
# pkg info
brotli-1.2.0,1 Generic-purpose lossless compression algorithm
curl-8.21.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_2,1 LZ4 compression library, lossless and very fast
libnghttp2-1.69.0 HTTP/2 C Library
libpsl-0.22.0 C library to handle the Public Suffix List
libssh2-1.11.1_1,3 Library implementing the SSH2 protocol
libunistring-1.4.2 Unicode string library
pkg-2.7.5 Package manager
zstd-1.5.7_2 Fast real-time compression algorithm
4. 先ほどインストールしたcurlの情報を取得する
# pkg info curl
curl-8.21.0
Name : curl
Version : 8.21.0
Installed on : Sat Sep 12 01:23:54 2026 JST
Origin : ftp/curl
Architecture : FreeBSD:14: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
----------------------------------------------------- -----------------------------------------
5.アプリケーションの削除
# pkg delete [package]
6.アプリケーションの更新状態を参照
# pkg version
brotli-1.2.0,1 =
curl-8.21.0 =
indexinfo-0.3.1_1 =
libidn2-2.3.8 =
liblz4-1.10.0_2,1 =
libnghttp2-1.69.0 =
libpsl-0.22.0 =
libssh2-1.11.1_1,3 =
libunistring-1.4.2 =
pkg-2.7.5 =
zstd-1.5.7_2 =
>: 現在インストールされているものより新しいバージョンがリリースされている場合
=: 現在インストールされているものと同等のバージョンがリリースされている場合
<: 現在インストールされているものより古いバージョンがリリースされている場合
7.Packagesの更新
# pkg upgrade [package]
全てのパッケージを更新する場合
# pkg upgrade
3 Ports Collectionのインストール
FreeBSD14ではportsnapが削除されていますのでgitを用いて,ポーツ・コレクション(ports collection) をダウンロード,アップデート(更新)する.
3.1. gitをインストールする
# pkg install git
3.2. Port Collectionのインストール
portsツリーのHEADブランチのコピーをチェックアウトする
すでにPort Collectionがある場合は削除しておく
# rm -Rf /usr/ports/*
# git clone --depth 1 https://git.FreeBSD.org/ports.git /usr/ports
/usr/portsを更新する
# git -C /usr/ports pull
3.3 perl5 アップグレード
インストールできるperlのバージョン確認
# pkg search lang/perl
lang/perl5-devel Practical Extraction and Report Language
lang/perl5.40 Practical Extraction and Report Language
lang/perl5.42 Practical Extraction and Report Language
lang/perl5.44 Practical Extraction and Report Language
今回は最新のperl5.44をインストールする
# cd /usr/ports/lang/perl5.44
# make NO_DIALOG=yes
# make reinstall
3.4 ports 用メンテナンスツール
まず「ports」の環境を整える
# 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
※python rubyのversionを指定する場合
python3.11の系列をメインに使用する
DEFAULT_VERSIONS+=python=3.11 python3=3.11
ruby3.3もしくは3.4の系列をメインに使用する
DEFAULT_VERSIONS+=ruby=3.3
「ports」をメンテナンスするための「ports」、「portupgrade」をインストールします。
# cd /usr/ports/ports-mgmt/portupgrade
# make config
オプションはデフォルト
# make NO_DIALOG=yes
# make reinstall
3.5. INDEXの更新
# portsdb -Fu
-F:INDEXファイル取得
-u:できたINDEXファイルを元にバイナリDBを更新
データベースの状態を参照するには
# portversion -v
[Reading data from pkg(8) ... - 66 packages found - done]
autoconf-2.73 = up-to-date with port
autoconf-switch-20220527 = up-to-date with port
automake-1.18.1 = up-to-date with port
brotli-1.2.0,1 = up-to-date with port
bsddialog-1.1 = up-to-date with port
curl-8.21.0 < needs updating (port has 8.22.0)
db5-5.3.28_10 = up-to-date with port
expat-2.8.2 < needs updating (port has 2.8.4)
gettext-runtime-1.0_1 = up-to-date with port
gettext-tools-1.0 = up-to-date with port
git-2.54.0 < needs updating (port has 2.55.0)
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
libffi-3.6.0 < needs updating (port has 3.8.0)
libiconv-1.18_1 = up-to-date with port
libidn2-2.3.8 = up-to-date with port
liblz4-1.10.0_2,1 = up-to-date with port
libnghttp2-1.69.0 < needs updating (port has 1.70.0)
libpsl-0.22.0 < needs updating (port has 0.23.3)
libssh2-1.11.1_1,3 = up-to-date with port
libtextstyle-1.0 = up-to-date with port
libunistring-1.4.2 = up-to-date with port
libunwind-20250904 = up-to-date with port
libxml2-2.15.4 = up-to-date with port
libyaml-0.2.5 = up-to-date with port
m4-1.4.21,1 = up-to-date with port
mpdecimal-4.0.1 = up-to-date with port
muon-0.6.0 = up-to-date with port
p5-Authen-SASL-2.1900 = up-to-date with port
p5-Crypt-URandom-0.54 = up-to-date with port
p5-Digest-HMAC-1.05 = up-to-date with port
p5-Error-0.17030 = up-to-date with port
p5-IO-Socket-SSL-2.099 = up-to-date with port
p5-Locale-gettext-1.07 = up-to-date with port
p5-Locale-libintl-1.37 = up-to-date with port
p5-MIME-Base32-1.303 = up-to-date with port
p5-MIME-Base64-3.16 = up-to-date with port
p5-Mozilla-CA-20260813 = up-to-date with port
p5-Net-SSLeay-1.94 = up-to-date with port
p5-Text-Unidecode-1.30 = up-to-date with port
p5-URI-5.34 = up-to-date with port
p5-Unicode-EastAsianWidth-12.0 = up-to-date with port
pcre2-10.47_1 < needs updating (port has 10.48)
perl5-5.42.3 = up-to-date with port
perl5.44-5.44.0 = up-to-date with port
pkg-2.7.5 < needs updating (port has 2.8.4)
pkgconf-3.0.5,1 = up-to-date with port
portconfig-0.6.2_2 = up-to-date with port
portupgrade-2.4.16_4,2 = up-to-date with port
python311-3.11.16 = up-to-date with port
python312-3.12.14 = up-to-date with port
readline-8.3.3 = up-to-date with port
ruby-3.3.12,1 = up-to-date with port
ruby33-bdb-0.6.6_9 = up-to-date with port
ruby33-gems-4.0.20 = up-to-date with port
rubygem-erb-6.0.7 = up-to-date with port
rubygem-logger-1.7.0 = up-to-date with port
rubygem-prism-1.9.0 = up-to-date with port
rubygem-rake-13.4.2 = up-to-date with port
rubygem-rbs-4.2.0 = up-to-date with port
rubygem-rdoc-8.0.0 = up-to-date with port
rubygem-tsort-0.2.0 = up-to-date with port
samurai-1.3 = up-to-date with port
texinfo-7.3_1,1 = up-to-date with port
zstd-1.5.7_2 = up-to-date with port
「=」マークがついていれば、最新版がインストールされている
「<」マークがついていれば、「ports」に新しい版が存在する
3.6. ports のアップグレード
上記で確認した結果、新しいバージョンが出ている「ports」を更新する
# portupgrade expat
