閲覧者からのリクエストを Apache が受けて WebLogic Server へ転送しています。
実は WebLogic にも HTTP Server 機能はありますが、Apache ほど高性能ではないため、Web Server として Apache を利用しています。
サーバーやネットワークの環境も関連しますが、数十人くらいの社内環境なら WebLogic Server だけで問題なく Web アプリは動きます。
Apache 2.4 のインストール
最初に yum コマンドで httpd(Apache)をインストールします。
[root@test07 ~]# yum install httpd
httpd.service の自動起動の設定をします。
[root@test07 ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@test07 ~]# systemctl start httpd.service
[root@test07 ~]# systemctl status httpd.service ● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since 水 2017-08-09 22:53:17 JST; 5s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 3822 (httpd)
Status: “Processing requests…”
CGroup: /system.slice/httpd.service
tq3822 /usr/sbin/httpd -DFOREGROUND
tq3824 /usr/sbin/httpd -DFOREGROUND
tq3825 /usr/sbin/httpd -DFOREGROUND
tq3826 /usr/sbin/httpd -DFOREGROUND
tq3827 /usr/sbin/httpd -DFOREGROUND
mq3828 /usr/sbin/httpd -DFOREGROUND
8月 09 22:53:17 test07 systemd[1]: Starting The Apache HTTP Server…
8月 09 22:53:17 test07 httpd[3822]: AH00558: httpd: Could not reliably determine the server’s f…sage
8月 09 22:53:17 test07 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@test07 ~]#
WebLogic 用 Apache HTTP Server プラグインのインストール
次にプラグインをインストールします。
WebLogic 用 Apache HTTP Server プラグインとは
Apache HTTP Server プラグインは、Apache HTTP サーバから WebLogic Server クラスタまたはインスタンスへリクエストをプロキシします。
具体的には「mod_weblogic」は、Apache HTTP サーバーの一部で Apache HTTP サーバーから WebLogic Server へのプロキシリスエストを許可します。
WebLogic 用 Apache HTTP Server プラグインのダウンロード
この「WebLogic用のプラグイン」ですが、正直言ってどこにあるのか非常に分かりにくいです。。
最新の「WebLogic 用 Apache HTTP Server プラグイン」をダウンロードする場合は、以下の手順で見つけてください。
#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule’ lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l’) do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf LoadModule weblogic_module modules/mod_wl_24.so ← この1行を追加します。
<Location /benefits> ← 今回は「http://192.168.1.10:7001/benefits」に対して BASIC 認証を設定するので「/benefits」にします。
SetHandler weblogic-handler
WebLogicPort 7001
WebLogicHost localhost
AuthUserFile /etc/httpd/conf/.htpasswd
AuthName “This is a Protected Area” ← test でも account_test でも何でもいいです。
AuthType Basic
Require valid-user
</Location>
Apache の起動
httpd サービスを自動起動にする設定にして、サービスを起動します。
# systemctl enable httpd.service
# systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See “systemctl status httpd.service” and “journalctl -xe” for details. ← エラーで起動ができませんでした。
# systemctl -l status httpd ← 原因を調べます。 ● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed(Result: exit-code) since 金 2017-08-11 12:40:05 JST; 8s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 30596 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 30586 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 30586 (code=exited, status=1/FAILURE)
8月 11 12:40:05 test07 systemd[1]: Starting The Apache HTTP Server…
8月 11 12:40:05 test07 httpd[30586]: httpd: Syntax error on line 58 of /etc/httpd/conf/httpd.conf: Cannot load modules/mod_wl_24.so into server: /etc/httpd/modules/mod_wl_24.so: cannot open shared object file: Permission denied ← 一見すると権限の問題に見えます。
8月 11 12:40:05 test07 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
8月 11 12:40:05 test07 kill[30596]: kill: cannot find process “”
8月 11 12:40:05 test07 systemd[1]: httpd.service: control process exited, code=exited status=1
8月 11 12:40:05 test07 systemd[1]: Failed to start The Apache HTTP Server.
8月 11 12:40:05 test07 systemd[1]: Unit httpd.service entered failed state.
8月 11 12:40:05 test07 systemd[1]: httpd.service failed.
「httpd: Syntax error on line 58 of /etc/httpd/conf/httpd.conf: Cannot load modules/mod_wl_24.so into server: /etc/httpd/modules/mod_wl_24.so: cannot open shared object file: Permission denied」のエラーについて「/var/log/messages」を調査したところ、答えが出ていました!
Aug 11 15:02:36 test07 systemd: Starting The Apache HTTP Server…
Aug 11 15:02:36 test07 httpd: [Fri Aug 11 15:02:36.807083 2017] [so:warn] [pid 3705] AH01574: module headers_module is already loaded, skipping Aug 11 15:02:36 test07 httpd: httpd: Syntax error on line 58 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_wl_24.so into server: /etc/httpd/modules/mod_wl_24.so: cannot open shared object file: Permission denied
Aug 11 15:02:36 test07 systemd: httpd.service: main process exited, code=exited, status=1/FAILURE
Aug 11 15:02:36 test07 kill: kill: cannot find process “”
Aug 11 15:02:36 test07 systemd: httpd.service: control process exited, code=exited status=1
Aug 11 15:02:36 test07 systemd: Failed to start The Apache HTTP Server.
Aug 11 15:02:36 test07 systemd: Unit httpd.service entered failed state.
Aug 11 15:02:36 test07 systemd: httpd.service failed.
Aug 11 15:02:36 test07 dbus[655]: [system] Activating service name=’org.fedoraproject.Setroubleshootd’ (using servicehelper)
Aug 11 15:02:36 test07 dbus-daemon: dbus[655]: [system] Activating service name=’org.fedoraproject.Setroubleshootd’ (using servicehelper)
Aug 11 15:02:39 test07 dbus[655]: [system] Successfully activated service ‘org.fedoraproject.Setroubleshootd’
Aug 11 15:02:39 test07 dbus-daemon: dbus[655]: [system] Successfully activated service ‘org.fedoraproject.Setroubleshootd’
Aug 11 15:02:42 test07 setroubleshoot: failed to retrieve rpm info for /usr/lib64/httpd/modules/mod_wl_24.so
Aug 11 15:02:42 test07 setroubleshoot: SELinux is preventing /usr/sbin/httpd from open access on the file /usr/lib64/httpd/modules/mod_wl_24.so. For complete SELinux messages. run sealert -l 059555ba-6836-4746-b427-d49c29b9007b ← ここに答えが出ていました。
Aug 11 15:02:42 test07 python: SELinux is preventing /usr/sbin/httpd from open access on the file /usr/lib64/httpd/modules/mod_wl_24.so.#012#012***** Plugin restorecon (92.2 confidence) suggests ************************#012#012If you want to fix the label. #012/usr/lib64/httpd/modules/mod_wl_24.so default label should be httpd_modules_t.#012Then you can run restorecon.#012Do#012# /sbin/restorecon -v /usr/lib64/httpd/modules/mod_wl_24.so#012#012***** Plugin catchall_boolean (7.83 confidence) suggests ******************#012#012If you want to allow httpd to read user content#012Then you must tell SELinux about this by enabling the ‘httpd_read_user_content’ boolean.#012You can read ‘None’ man page for more details.#012Do#012setsebool -P httpd_read_user_content 1#012#012***** Plugin catchall (1.41 confidence) suggests **************************#012#012If you believe that httpd should be allowed open access on the mod_wl_24.so file by default.#012Then you should report this as a bug.#012You can generate a local policy module to allow this access.#012Do#012allow this access for now by executing:#012# ausearch -c ‘httpd’ –raw | audit2allow -M my-httpd#012# semodule -i my-httpd.pp#012
「SELinux is preventing /usr/sbin/httpd from open access on the file /usr/lib64/httpd/modules/mod_wl_24.so.」のメッセージを翻訳すると、「A privent B from C」は「Aは、BがCしないように防ぐ」なので、「SELINUXは、httpd が mod_wl_24.so にアクセスしないように防いだ」という意味になります。
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
#SELINUX=enforcing SELINUX=disabled ← SELINUX を「disabled」にします。
# SELINUXTYPE= can take one of three two values:
# targeted – Targeted processes are protected,
# minimum – Modification of targeted policy. Only selected processes are protected.
# mls – Multi Level Security protection.
SELINUXTYPE=targeted
SELINUX を変更したら OS を reboot します。
# reboot
再起動後に「Disabled」になっていることを確認します。
# getenforce Disabled ← 「Disabled」になっています。
httpd.serviceのステータスを確認します。
# systemctl -l status httpd.service ● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed(Result: exit-code) since 金 2017-08-11 15:27:58 JST; 2min 1s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3544 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 3541 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 3541 (code=exited, status=1/FAILURE)
8月 11 15:27:57 test07 systemd[1]: Starting The Apache HTTP Server…
8月 11 15:27:58 test07 httpd[3541]: [Fri Aug 11 15:27:58.086180 2017] [so:warn] [pid 3541] AH01574: module headers_module is already loaded, skipping
8月 11 15:27:58 test07 httpd[3541]: httpd: Syntax error on line 58 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_wl_24.so into server: libopmnsecure.so: cannot open shared object file: No such file or directory ← パスがおかしい?ファイルが見つからないと言っています。
8月 11 15:27:58 test07 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
8月 11 15:27:58 test07 kill[3544]: kill: cannot find process “”
8月 11 15:27:58 test07 systemd[1]: httpd.service: control process exited, code=exited status=1
8月 11 15:27:58 test07 systemd[1]: Failed to start The Apache HTTP Server.
8月 11 15:27:58 test07 systemd[1]: Unit httpd.service entered failed state.
8月 11 15:27:58 test07 systemd[1]: httpd.service failed.
# httpd -M ← 動的にロードされたモジュール一覧
[Fri Aug 11 15:43:27.637504 2017] [so:warn] [pid 3738] AH01574: module headers_module is already loaded, skipping
[Fri Aug 11 15:43:27.735131 2017] [weblogic:warn] [pid 3738] The Debug directive is ignored. The web server log level is used instead.
[Fri Aug 11 15:43:27.735159 2017] [weblogic:warn] [pid 3738] The WLLogFile directive is ignored. The web server log file is used instead.
「httpd: Syntax error on line 58 of /etc/httpd/conf/httpd.conf: Cannot load /etc/httpd/modules/mod_wl_24.so into server: libopmnsecure.so: cannot open shared object file: No such file or directory」のメッセージが出る原因は「httpd.conf」ファイルに「LoadModule」の設定が入っていないから
Job for httpd.service failed because a fatal signal was delivered to the control process. See “systemctl status httpd.service” and “journalctl -xe” for details. ← 再度エラーになりました。
ログを確認します。
「ServerName」の設定がないことでエラーが出力されているようです。
# systemctl -l status httpd.service ● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: signal) since 金 2017-08-11 17:49:20 JST; 1min 46s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 4484 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 5578 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=killed, signal=KILL)
Main PID: 5578 (code=killed, signal=KILL)
Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”
CGroup: /system.slice/httpd.service
8月 11 17:46:19 test07 systemd[1]: Starting The Apache HTTP Server…
8月 11 17:46:52 test07 httpd[5578]: AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 192.168.1.10. Set the ‘ServerName’ directive globally to suppress this message
8月 11 17:47:50 test07 systemd[1]: httpd.service start operation timed out. Terminating.
8月 11 17:49:20 test07 systemd[1]: httpd.service stop-final-sigterm timed out. Killing.
8月 11 17:49:20 test07 systemd[1]: httpd.service: main process exited, code=killed, status=9/KILL
8月 11 17:49:20 test07 systemd[1]: Failed to start The Apache HTTP Server.
8月 11 17:49:20 test07 systemd[1]: Unit httpd.service entered failed state.
8月 11 17:49:20 test07 systemd[1]: httpd.service failed.
再度「/etc/httpd/conf/httpd.conf」ファイルを編集します。
# vi /etc/httpd/conf/httpd.conf
#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn’t have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80 ServerName test07 ← 「ServerName」を追加します。
This element defines servlet used in the application. If a jsp-file is specified and the <load-on-startup> element is present, then the JSP is precompiled and loaded when WebLogic Server starts in the order of value given in <load-on-startup>.
After all the servlets are defined, they need to be mapped to the URL pattern. The portion of the URL after the http://host:port + WebAppName is compared to the <url-pattern> by WebLogic Server. If the patterns match, the servlet mapped in this element will be called.
コメント