Skip to content
VDS · オペレーティングシステム

AlmaLinuxとCentOS Stream:aptではなくdnf

Debian向けの手順をRHEL系に合わせる方法を説明します。コマンドとパッケージの対応、ufwの代わりにfirewalld、SELinux、EPELリポジトリについてです。

更新日 2026年8月23日

AlmaLinux 9 と 10、および CentOS Stream 9 は Debian や Ubuntu とは動作が異なります。ここでは、よくつまずくポイントを確認していきましょう。

コマンドの対応表

Debian / UbuntuAlmaLinux / CentOS Stream
apt update && apt upgradednf upgrade
apt install packagednf install package
apt remove packagednf remove package
apt search stringdnf search string
apt list --installeddnf list installed
ufwfirewall-cmd
グループ sudoグループ wheel
/etc/apt/sources.list/etc/yum.repos.d/

パッケージ名も異なります。apache2 はここでは httpd、nginx は同じ、mysql-server は mariadb-server、python3-pip は python3-pip ですが、dnsutils は bind-utils という名前になっています。

最初のステップ

dnf upgrade -y
dnf install -y curl nano git htop tar policycoreutils-python-utils
timedatectl set-timezone Europe/Moscow
hostnamectl set-hostname my-vds

管理者権限を持つユーザー:

adduser artem
passwd artem
usermod -aG wheel artem

EPEL リポジトリ

よく使うパッケージの多くはベースリポジトリには含まれておらず、EPEL にあります:

dnf install -y epel-release
dnf upgrade -y
dnf install -y btop fail2ban

ファイアウォール

ufw の代わりに、ここでは firewalld を使用します:

systemctl enable --now firewalld
firewall-cmd --permanent --add-service=ssh
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload
firewall-cmd --list-all

--permanent を付けないと再起動後にルールが消えてしまい、--reload を付けないと今すぐには適用されません。両方の指定が必要です。

SELinux

原因不明の障害の主な発生源です。ファイルのパーミッションは正しく、サービスも起動しているのにアクセスできない、という状況が起こります。モードを確認するには:

getenforce

よくあるケースと解決方法:

setsebool -P httpd_can_network_connect 1
semanage port -a -t http_port_t -p tcp 8080
restorecon -Rv /var/www

1 つ目は Web サーバーに外向きの接続を許可するもの(アプリケーションへのプロキシ時に必要)、2 つ目は標準以外のポートでの待ち受けを許可するもの、3 つ目は他人のディレクトリからコピーした後のファイルラベルを修正するものです。

実際に何が起きているかは、こちらで確認できます:

ausearch -m avc -ts recent

SELinux を完全に無効化する必要はありません。ほとんどの場合、上記 3 つの手法のいずれかで十分です。

そのほかの違い

  • Apache Web サーバーは httpd という名前で、設定は /etc/apache2/ ではなく /etc/httpd/ にあります。
  • nginx には sites-available や sites-enabled ディレクトリはなく、設定は /etc/nginx/conf.d/*.conf に置きます。
  • Web サーバーのユーザーは www-data ではなく nginx または apache です。これは chown を使う際に重要になります。

ゲストエージェント

dnf install -y qemu-guest-agent
systemctl enable --now qemu-guest-agent

この系統を選ぶべきか迷っている場合は、どの OS を選ぶかをご覧ください。OS は再インストールで変更できますが、データは完全に失われます。