
という URL を有効にする方法があり、このページには Apache サービスの動作メトリックが表示されると聞きましたhttp://<your host>/server-status
。しかし、その URL にアクセスするたびに、404 ページが見つかりませんというエラーが表示されます。設定方法は次のとおりです。
- オフィス ネットワークで新しい仮想マシンを起動します。このマシンのローカル IP アドレスは です
192.168.0.42
。マシンは Ubuntu 22.04 を使用します。 - を実行します
apt-get update && apt dist-upgrade -y && apt-get install -y apache2
。これにより、Apache 2.4.52 がインストールされます。 - 私が使用している Windows コンピュータのローカル IP アドレスは です
192.168.0.16
。このコンピュータから と入力するhttp://192.168.0.42
と、Apache のデフォルトの Web ページが表示されます。 - のマシンで
192.168.0.42
、 と入力しますa2enmod rewrite && a2enmod status
。 - 以下のファイルを提供します
// /etc/apache2/apache2.conf
DefaultRuntimeDir ${APACHE_RUN_DIR}
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
/etc/apache2/mods-available/status.conf && /etc/apache2/mods-enabled/status.conf
<IfModule mod_status.c>
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the "192.0.2.0/24" to allow access from other hosts.
<Location /server-status>
SetHandler server-status
Require local
Require ip 192.168.0.42/24
Require ip 192.168.0.16/24
</Location>
# Keep track of extended status information for each request
ExtendedStatus On
# Determine if mod_status displays the first 63 characters of a request or
# the last 63, assuming the request itself is greater than 63 chars.
# Default: Off
#SeeRequestTail On
<IfModule mod_proxy.c>
# Show Proxy LoadBalancer status in mod_status
ProxyStatus On
</IfModule>
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
次に、マシンsystemctl restart apache2
の bash ターミナルに入力します192.168.0.42
。
次に、Google Chrome ブラウザ経由で192.168.0.16
コンピューターを起動すると、404 が表示されます。http://192.168.0.42/server-status
wget http://192.168.0.42/server-status
のシェルからコマンドを実行すると192.168.0.42
、404 が返されます。
wget http://127.0.0.1/server-status
のシェルからコマンドを実行すると192.168.0.42
、404 が返されます。
wget http://localhost/server-status
のシェルからコマンドを実行すると192.168.0.42
、404 が返されます。
何が間違っているのでしょうか?