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

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

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

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

Q&A

解決済

3回答

3164閲覧

Apacheが起動しなくなりました。原因がわかりません。

akkkkin

総合スコア83

Apache

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

0グッド

0クリップ

投稿2016/12/02 07:07

編集2016/12/02 07:07

apachegが起動しなくなりました。

■起動確認のコマンド

$ ps agx | grep httpd 30122 pts/0 S+ 0:00 grep --color=auto httpd

となります。

おそらく下記あたりを触っていたせいかと思います。

Deny access to the entirety of your server's filesystem. You must # explicitly permit access to web content directories in other # <Directory> blocks below. # <Directory /> AllowOverride none Require all denied </Directory> # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # # Note that from this point forward you must specifically allow # particular features to be enabled - so if something's not working as # you might expect, make sure that you have specifically enabled it # below. # # # DocumentRoot: The directory out of which you will serve your # documents. By default, all requests are taken from this directory, but # symbolic links and aliases may be used to point to other locations. # DocumentRoot "/var/www/html/hoge" # # Relax access to content within /var/www. # <Directory "/var/www"> AllowOverride All # Allow open access: Require all granted </Directory>

どこを直せばいいのかさっぱりわかりません。
もし詳しい方いらしゃればご教示いただけますとありがたいです。

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

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

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

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

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

guest

回答3

0

1行目のコメント#がありません

投稿2016/12/02 07:13

katsuya141

総合スコア367

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

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

0

下記で設定ファイルのチェックを行ってみてください。
「Syntax OK」と表示されますか?

されない場合、エラーの内容にしたがって修正をして下さい。

shell

1apachectl configtest

投稿2016/12/02 07:12

himakuma

総合スコア952

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

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

akkkkin

2016/12/02 07:20

AH00526: Syntax error on line 134 of /etc/httpd/conf/httpd.conf: DocumentRoot not allowed here と表示されました。 134行目あたりは下記のような状態です。 133 DocumentRoot "/var/www/html/hoge" 134 # or any combination of: 135 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI Mul tiViews どこをどう直せばいいのでしょうか・・・・?
tacsheaven

2016/12/02 07:30

133行目より手前(上)の方にある、<Directory ...> ... </Directory> の、</Directory> が消えてしまっていませんか? DocumentRoot は設定ファイルのトップか、VirtualHost ディレクティブ内でのみ出現可能なので、<Directory> が終わっていないと構文不正でエラーになります。
akkkkin

2016/12/02 07:44

><Directory ...> ... </Directory> の、</Directory> が消えてしまっていませんか? 下記のように修正しました。 # Further relax access to the default document root: 131 <Directory "/var/www/html"> 132 # 133 </Directory> 134 DocumentRoot "/var/www/html/hoge" 135 # or any combination of: 136 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI Mul tiViews すると今度は下記のエラーがでました。 httpd: Syntax error on line 158 of /etc/httpd/conf/httpd.conf: </Directory> without matching <Directory> section
tacsheaven

2016/12/02 07:54

なるほど、わかりました。もともと <Directory "/var/www/html"> ~ </Directory>(現在の158行目)という中に、134行目の DocumentRoot を追加してたのでしょう。 上の修正をいったん外し、DocumentRoot を <Directory "/var/www/html">~</Directory>の中ではない場所に移動させましょう。
akkkkin

2016/12/02 15:30

134行目のhogeを追加していたので削除しました。これで一旦もとのドキュメントルートに戻っているはずなのですが、まだエラーが表示されます。 130 # Further relax access to the default document root: 131 <Directory "/var/www/html"> 132 # 133 DocumentRoot "/var/www/html" 134 # or any combination of: 135 # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI Mul tiViews としてもテスト結果は AH00526: Syntax error on line 133 of /etc/httpd/conf/httpd.conf: DocumentRoot not allowed here と表示されてしまいます。
tacsheaven

2016/12/03 00:05

だから、「DocumentRoot は Directory ディレクティブの中には書けない」のですよ。 133行目は、131行目から始まる Directory ディレクティブの中だから駄目なのです。
akkkkin

2016/12/03 01:53

apache動きました。ありがとうございます! どこを変更したかがわからないようになったら元に戻すことも出来ないし、 後で修正すらできなくなるのが怖いですね。 本当に助かりました!
guest

0

ベストアンサー

apache のエラーログに起動失敗時のエラー情報が書かれていませんか? それを読めば conf のどこが悪いのかわかると思います。

※まさかと思うけど、上げられた conf の先頭行(Deny Access...)のコメントが外れているせい、とか?

投稿2016/12/02 07:09

編集2016/12/02 07:11
tacsheaven

総合スコア13703

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問