httpd、php、php-mbstringインストール
[root@falcon21 ~]# dnf -y install httpd php php-mbstring
インストール済み:
mod_ssl インストール
root@falcon21:~# dnf -y install mod_ssl
Apache設定
Apache設定ファイル編集 [root@falcon21 ~]# vi /etc/httpd/conf/httpd.conf #ServerName www.example.com:80 ↓ ServerName falcon21.space:80 ← サーバー名を指定 <Directory “/var/www/html”> # # Possible values for the Options directive are “None”, “All”, # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that “MultiViews” must be named *explicitly* — “Options All” # doesn’t give it to you. # # 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 Indexes FollowSymLinks ↓ 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 None ↓ AllowOverride All ← .htaccessの許可 <IfModule dir_module> DirectoryIndex index.html index.php index.cgi index.shtml </IfModule> # # 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\”” commbined ← 長すぎる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 ← 上記以外のアクセスをログに記録する AddDefaultCharset UTF-8 ↓ #AddDefaultCharset UTF-8 ← コメントアウト(文字化け対応)?かえって文字化け #AddHandler cgi-script .cgi ↓ AddHandler cgi-script .cgi .pl ← CGIスクリプトに.plを追加 以下を最終行に追加 TraceEnable off ← Traceメソッドを無効化(クロスサイトトレーシング対策) ServerTokens Prod ———————- httpd チェック root@falcon21:~# apachectl -t Syntax OK —————- httpd 有効化 [root@falcon21 ~]# systemctl enable –now httpd Created symlink ‘/etc/systemd/system/multi-user.target.wants/httpd.service’ → ‘/usr/lib/systemd/system/httpd.service’. ———————- テストページ削除 [root@falcon21 ~]# rm -f /etc/httpd/conf.d/welcome.conf —————- /www/html/にテストページ作成 [root@falcon21 ~]# vi /var/www/html/index.html <html> <body> <h1 style=”width: 100%; font-size: 40px; text-align: center;”> 只今、メンテナンス中 </h1> </body> </html> —————- httpd 再起動 root@falcon21:~# systemctl restart httpd httpd 起動確認 root@falcon21:~# systemctl status httpd ● httpd.service – The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled) Drop-In: /etc/systemd/system/httpd.service.d └─php-fpm.conf Active: active (running) since Wed 2025-11-12 09:21:56 JST; 22s ago Invocation: dea95ddd28a14b83ae1abe8b4e6f2057 Docs: man:httpd.service(8) Main PID: 5568 (httpd) Status: “Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec“ Tasks: 177 (limit: 47782) Memory: 13.4M (peak: 14M) CPU: 104ms CGroup: /system.slice/httpd.service ├─5568 /usr/sbin/httpd -DFOREGROUND ├─5569 /usr/sbin/httpd -DFOREGROUND ├─5570 /usr/sbin/httpd -DFOREGROUND ├─5571 /usr/sbin/httpd -DFOREGROUND └─5572 /usr/sbin/httpd -DFOREGROUND 11月 12 09:21:56 falcon21.space systemd[1]: Starting httpd.service – The Apache HTTP Server… 11月 12 09:21:56 falcon21.space (httpd)[5568]: httpd.service: Referenced but unset environment variable evaluates to an empty string: O> 11月 12 09:21:56 falcon21.space httpd[5568]: Server configured, listening on: port 80 11月 12 09:21:56 falcon21.space systemd[1]: Started httpd.service – The Apache HTTP Server. ~ *********************************************************************** TCP80番ポート開放 cockpit → ネットワーキング → ファイアーウォール サーバーデスクトップアプリ 「ファイアーウォール設定」で確認 サービス http 80 *********************************************************************** index.html ウェブページ表示確認 http://192.168.10.3/ 只今、メンテナンス中 サーバーデスクトップ・firefox で表示 ドメインでは表示できない。 Windows PC では、表示できない。 ssl 設定が必要 *********************************************************************** Perlコマンドへ/usr/local/bin/perlでもアクセスできるようにする。 /usr/local/bin/perlから/usr/bin/perlへリンクをはる [root@falcon21 ~]# ln -s /usr/bin/perl /usr/local/bin/perl Perlのパスを確認 [root@falcon21 ~]# whereis perl perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz ← Perlのパスに/usr/local/bin/perlが表示されることを確認 CGIページ確認 CGIテストページ作成 [root@falcon21 ~]# vi /var/www/html/test.cgi #!/usr/local/bin/perl print “Content-type: text/html\n\n”; print “<html>\n”; print “<head>\n”; print “<meta http-equiv=\”Content-Type\” content=\”text/html; charset=UTF-8\”>\n”; print “<title>テスト</title>\n”; print “</head>\n”; print “<body>\n”; print “CGIテスト\n”; print “</body>\n”; print “</html>\n”; テスト用CGIパーミッション変更 [root@falcon21 ~]# chmod 755 /var/www/html/test.cgi http://192.168.10.3/test.cgi にアクセス CGIテスト OK!! ************************************************************************ PHPページ確認 PHPテストページ作成 [root@falcon21 ~]# vi /var/www/html/test.php <?php phpinfo(); ?> http://192.168.10.3/test.php にアクセス phpinfo ページ表示 OK!! *********************************************************************** SSI確認 SSIで現在日時を表示してみる。 SSIテスト用ページ作成 [root@falcon21 ~]# vi /var/www/html/test.shtml <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″> <title>テスト</title> </head> <body> SSIテスト <!–#config timefmt=”%Y/%m/%d %H:%M:%S” –> <!–#echo var=”DATE_LOCAL” –> </body> </html> http://192.168.10.3/test.shtml にアクセス SSIテスト 2025/11/12/22:57:02 日時を表示 OK!! |