質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

MariaDB

MariaDBは、MySQL派生のオープンソースなリレーショナルデータベースシステムです。 また、MySQLとほぼ同じデータベースエンジンに対応しています。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

Q&A

解決済

1回答

7877閲覧

VPSでApacheを使用して環境構築をしたいがうまくいかない

mach-sim

総合スコア6

CentOS

CentOSは、主にRed Hat Enterprise Linux(RHEL)をベースにした、フリーのソフトウェアオペレーティングシステムです。

Apache

Apacheは、Apache HTTP Serverの略で、最も人気の高いWebサーバソフトウェアの一つです。安定性が高いオープンソースソフトウェアとして商用サイトから自宅サーバまで、多くのプラットフォーム向けに開発・配布されています。サーバーソフトウェアの不具合(NCSA httpd)を修正するパッチ(a patch)を集積、一つ独立したソフトウェアとして開発されました。

MariaDB

MariaDBは、MySQL派生のオープンソースなリレーショナルデータベースシステムです。 また、MySQLとほぼ同じデータベースエンジンに対応しています。

VPS

VPS(バーチャル・プライベート・サーバ)は、仮想化されたサーバをレンタルするサービスで、共有サーバでありながら専門サーバと同等の機能を果たします。物理的な専門サーバより安価で提供できるメリットがあります。

0グッド

0クリップ

投稿2021/05/17 04:04

前提・実現したいこと

OSSの開発環境を作るためにApacheを使ってVPSでページを立ち上げようとしますがエラーコード500の内部サーバーエラーが発生してしまいます。Apacheのエラーログを見るとこ以下のようなエラーが出ていました。

発生している問題・エラーメッセージ

[root@localhost logs]# tail -f error_log [Mon May 17 12:14:19.129160 2021] [mpm_event:notice] [pid 40026:tid 139716742412608] AH00489: Apache/2.4.37 (centos) configured -- resuming normal operations [Mon May 17 12:14:19.129214 2021] [core:notice] [pid 40026:tid 139716742412608] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND' [Mon May 17 12:26:14.666149 2021] [mpm_event:notice] [pid 40026:tid 139716742412608] AH00492: caught SIGWINCH, shutting down gracefully [Mon May 17 12:26:15.797978 2021] [core:notice] [pid 40416:tid 140418124097856] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Mon May 17 12:26:15.800433 2021] [suexec:notice] [pid 40416:tid 140418124097856] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message [Mon May 17 12:26:15.836553 2021] [lbmethod_heartbeat:notice] [pid 40416:tid 140418124097856] AH02282: No slotmem from mod_heartmonitor [Mon May 17 12:26:15.837880 2021] [http2:warn] [pid 40416:tid 140418124097856] AH02951: mod_ssl does not seem to be enabled [Mon May 17 12:26:15.843065 2021] [mpm_event:notice] [pid 40416:tid 140418124097856] AH00489: Apache/2.4.37 (centos) configured -- resuming normal operations [Mon May 17 12:26:15.843118 2021] [core:notice] [pid 40416:tid 140418124097856] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

該当のソースコード

/etc/httpd/conf/httpd.confから一部抜粋 'Main' server configuration # # The directives in this section set up the values used by the 'main' # server, which responds to any requests that aren't handled by a # <VirtualHost> definition. These values also provide defaults for # any <VirtualHost> containers you may define later in the file. # # All of these directives may appear inside <VirtualHost> containers, # in which case these default settings will be overridden for the # virtual host being defined. # # # ServerAdmin: Your address, where problems with the server should be # e-mailed. This address appears on some server-generated pages, such # as error documents. e.g. admin@your-domain.com # ServerAdmin root@localhost # # 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 localhost:80

試したこと

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message と書かれた箇所に原因があるようですが記事をみて修正してみましたが変化はありませんでした。

補足情報(FW/ツールのバージョンなど)

apache2.4
centOS8
mariaDB
googlechrome

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2021/05/17 04:52

何を頼りに設定作業を進めているのか、参考にしているものがあれば示してください。
otn

2021/05/17 06:29

> VPSでページを立ち上げようとしますが 立ち上がっているのでは? > エラーコード500の内部サーバーエラーが発生してしまいます。 500は普通は、Apacheが立ち上がってブラウザ等でリクエストした際にブラウザ画面に表示されるエラーですが、そういうことではない??どこに500と出ているのでしょう?
mach-sim

2021/05/17 06:39

>500は普通は、Apacheが立ち上がってブラウザ等でリクエストした際にブラウザ画面に表示されるエラーですが、そういうことではない??どこに500と出ているのでしょう? 自分の認識違いでしたら申し訳ありません。 確かにページ上にはリクエストを受け付けた表示があり内部サーバーエラーとなっています。そしてコンソールログにFailed to load resource: the server responded with a status of 500 (Internal Server Error) と表示されています。
退会済みユーザー

退会済みユーザー

2021/05/17 07:03

まず、index.htmlファイルとか置いて、apache httpdの動作自体は問題がなくて、cgi側なのか、モジュール動作しているphpの方なのかなど絞り込んでいただきたく。error_logもチェックして。
otn

2021/05/17 13:02

>確かにページ上にはリクエストを受け付けた表示があり内部サーバーエラーとなっています。 ブラウザでどういうページにアクセスしたとかの情報が全くありません。
guest

回答1

0

ベストアンサー

業者さんのVPSサーバーでしたら、
独自ドメインは設定していますかね?

ドメイン設定していなければ、業者さんの管理上のサーバー名やサーバー・ドメインが決まっているはずなので、
それをhttpd.confに反映する必要があるかと。

「#ServerName localhost:80」

の箇所、「#」によるコメントアウトを外して、
VPS契約上のサーバー名を設定すれば、ひとまず動くはず。

httpd.confやそれらから読み込む関連ファイルのファイルのオーナーユーザー:グループもチェック。


あと、SELinuxが有効になっているようですが、
ドキュメントルートなどのコンテンツに対するフラグは大丈夫でしょうか。
httpd_sys_content_tやhttpd_sys_rw_content_tなど、
ディレクトリやファイルに対して適切に施さないとうまく行かない場合があります。

SELinux ユーザーおよび管理者のガイド Red Hat Enterprise Linux 7 | Red Hat Customer Portal
4.7. SELinux コンテキスト: ファイルのラベル付け Red Hat Enterprise Linux 7 | Red Hat Customer Portal
14.4. 設定例 Red Hat Enterprise Linux 7 | Red Hat Customer Portal

面倒であれば、SELinuxを無効化して動かせばいいですが、
なるべくは有効にしたまま、やっていただきたく。


httpd.serviceの再起動とかやってますよねぇ?
この現象に近い気がするのですが。
メッセージを表示するだけで、止まってはいないのでは?
LogLevelを調整してもう少し詳しく追ったほうがいいかもしれない。

「SELinux policy enabled」でApacheが起動しない - hogehoge foobar Blog Style Beta

「SELinuxのせいで動かない」撲滅ガイド - Qiita

投稿2021/05/17 04:46

編集2021/05/17 07:01
退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

mach-sim

2021/05/17 05:33

コメントアウトを外しドメインを入力したところ問題のエラーはなくなりましたがサーバーエラーは解決しませんでした。 [Mon May 17 14:26:40.210108 2021] [mpm_event:notice] [pid 42273:tid 140204447148352] AH00492: caught SIGWINCH, shutting down gracefully [Mon May 17 14:26:41.340398 2021] [core:notice] [pid 42864:tid 140448241805632] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Mon May 17 14:26:41.342690 2021] [suexec:notice] [pid 42864:tid 140448241805632] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec) [Mon May 17 14:26:41.378026 2021] [lbmethod_heartbeat:notice] [pid 42864:tid 140448241805632] AH02282: No slotmem from mod_heartmonitor [Mon May 17 14:26:41.379348 2021] [http2:warn] [pid 42864:tid 140448241805632] AH02951: mod_ssl does not seem to be enabled [Mon May 17 14:26:41.389506 2021] [mpm_event:notice] [pid 42864:tid 140448241805632] AH00489: Apache/2.4.37 (centos) configured -- resuming normal operations [Mon May 17 14:26:41.389562 2021] [core:notice] [pid 42864:tid 140448241805632] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
mach-sim

2021/05/17 06:50

開発用のサーバーなのでSELinuxは無効で大丈夫ですので無効にしてありますがエラーが出続けてしまっっています。 [root@localhost logs]# getenforce Permissive [Mon May 17 15:43:44.162765 2021] [core:notice] [pid 4095:tid 140198587545920] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0
mach-sim

2021/05/18 01:57 編集

エラーログを確認したところapacheのconfファイルにあるDocumentRootのパスが間違っていたようです。 無事稼働し、それ以外のエラーは特に影響はありませんでした。ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問