Apacheインストール
[root@almalinux ~]# dnf -y install httpd php php-mbstring ※ httpd、php、php-mbstringインストール
メタデータの期限切れの最終確認: 2:19:24 前の 2026年05月26日 13時43分24秒 に実施しました。
依存関係が解決しました。
===============================================================================================================
パッケージ Arch バージョン リポジトリー サイズ
===============================================================================================================
インストール:
httpd x86_64 2.4.62-7.el9_7.3 appstream 45 k
(途中省略)
「ブロックタイプを変換」
php-mbstring-8.0.30-5.el9_7.x86_64 php-opcache-8.0.30-5.el9_7.x86_64
php-pdo-8.0.30-5.el9_7.x86_64 php-xml-8.0.30-5.el9_7.x86_64
完了しました!Apache設定
(1)Apache設定
[root@almalinux ~]# vi /etc/httpd/conf/httpd.conf ※ Apache設定ファイル編集
# If your host doesn't have a registered DNS name, enter its IP address here.
#
ServerName softdev-learn.cc:80 ← コメント解除してサーバー名を指定
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
Options Includes ExecCGI FollowSymLinks ← CGI,SSIの許可
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All ← .htaccessの許可
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined ← 長すぎるURI(414エラー)はログに記録しない
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
SetEnvIf Remote_Addr 192.168.10 no_log ← 追加(内部からのアクセスをログに記録しない)
SetEnvIf Remote_Addr 127.0.0.1 no_log ← 追加(自ホストからのアクセスをログに記録しない)
CustomLog "logs/access_log" combined env=!no_log env=!no_log ← 上記以外のアクセスをログに記録する
# Specify a default charset for all content served; this enables
# interpretation of all content as UTF-8 by default. To use the
# default browser choice (ISO-8859-1), or to allow the META tags
# in HTML content to override this choice, comment out this
# directive:
#
#AddDefaultCharset UTF-8 ← コメントアウト(文字化け対応)
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .pl ← CGIスクリプトに.plを追加
※以下を最終行に追加
TraceEnable off ← Traceメソッドを無効化(クロスサイトトレーシング対策)(2)Perlコマンドへ/usr/local/bin/perlでもアクセスできるようにする。
[root@almalinux ~]# ln -s /usr/bin/perl /usr/local/bin/perl ※ /usr/local/bin/perlから/usr/bin/perlへリンクをはる
[root@almalinux ~]# whereis perl ※ Perlのパスを確認
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz ※ Perlのパスに/usr/local/bin/perlが表示されることを確認(3)ドキュメントルート所有者変更
[root@almalinux ~]# chown almalinux. /var/www/html/ ※ ドキュメントルート所有者を変更
[root@almalinux ~]# ll /var/www/ ※ ドキュメントルート所有者変更確認
合計 0
drwxr-xr-x. 2 root root 6 12月 23 07:37 cgi-bin
drwxr-xr-x. 2 almalinux almalinux 6 12月 23 07:37 htmlApache起動
(1)Apache起動
[root@almalinux ~]# systemctl start httpd ※ Apache起動
[root@almalinux ~]# systemctl enable httpd ※ Apache自動起動設定
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.(2)Webサーバーアクセス確認
rm -f /var/www/html/index.html ※ テストページ削除ブラウザで「192.168.10.150」にアクセスし、「test」と表示されればOK


コメント