【Windows】MAMPがつながらないときの解決方法(仮)

WindowsのWordPress開発環境を整えるためにMAMPを使っています。

しかし、いつのころからかMAMPが接続できなくて、色々ネットでググりながら解決方法を試してみては失敗を繰り返し、半ばMAMPでの接続をあきらめていました。

でも、やっぱりMAMPは楽なので使いたい!

思いついたサイト案も開発してみたいということで、MAMPの接続できない理由を探ってみました。

接続ランプはついているのにNot Foundになってしまう

直面していたエラー状況は以下のとおりです。

MAMP起動後にApache ServerおよびMySQL Serverの接続ランプがついているにもかかわらず、

接続したいディレクトリにアクセスすると、Not Foundになってしまうという事例です。

で、この結果を受けて、Apacheサーバが起動していないのかなぁと思ったのですが、

MAMPのTopページだけは表示されているという。

Apacheについては正直ほとんど理解してませんが、lacalhostと指定したポート(18888)でこのMAMPTOPページに接続できていることを考えると、Apacheは少なくとも起動しているのかなという印象です。

MAMP\logs\apache_error.logを確認

MAMP内のapache_error.logを確認してみます。ここには、apache起動が失敗した場合のエラー報告や警告がログとして残されています。

そこには、たくさんのエラーが出まくっています。おそらく過去に何度も失敗し、表示されていたエラーログがてんこ盛りです。その中の最新のエラーログを見るとこんな感じになっていました。

[Sat Jan 20 18:45:53 2018] [error] [client 127.0.0.1] File does not exist: C:/MAMP/bin/mamp/wordpress

そもそも時間が実際のものとは合っていないのですが、メッセージを見ると、C:/MAMP/bin/mamp/wordpressにファイルがないから表示されないよーと言われてしまいました。

ん?

C:/MAMP/bin/mamp/ ってディレクトリはなんだ?という気分です。

おかしいなぁ。

ドキュメントルートは設定でもhtdocsになっているはずなのに、どういうことなのか?といった気分です。

設定はこうなっているけど、もしかしたらソース上では変わってないのかなと思ってC:\MAMP\conf\apache\httpd.confのファイルを見てみると、以下の表示になっていました。正直このhttpd.confの意味がほとんど理解できていないので、該当部分が以下のものであっているかは不明ですが、一応載せてみようと思います。

#
# 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 “C:\MAMP\htdocs”

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the “default” to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride None
Order deny,allow
Allow from all
</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.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory “C:\MAMP\htdocs”>
#
# 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.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks ExecCGI

#
# 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 All

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

# SetHandler perl-script
# PerlResponseHandler ModPerl::Registry
# PerlOptions +ParseHeaders
# Options +ExecCGI
# Order allow,deny
# Allow from all

#<IfModule mod_perl.c>
# # Files directive is only valid in Directory section
# <Files ~ “\.(pl|cgi)$”>
# SetHandler perl-script
# #PerlHandler ModPerl::Registry
# Options Indexes FollowSymLinks ExecCGI
# allow from all
#
# PerlSendHeader On
# </Files>
# </IfModule>

</Directory>

C:\MAMP\conf\apache\httpd.conf

コードを見るに、ドキュメントルートは設定どおり、C:\MAMP\htdocs”となっているらしいです。

解決策は…

で、まぁ解決策となるのですが、完全に方向性を見失ったので、最初のエラーログのメッセージに戻ります。

[Sat Jan 20 18:45:53 2018] [error] [client 127.0.0.1] File does not exist: C:/MAMP/bin/mamp/wordpress

おそらくなんらかの理由で、ドキュメントルートに指定したhtdocsを参照しなければならないところが、C:/MAMP/bin/mamp/wordpressというディレクトリを参照しているから、ファイルがないよと言っているんだと思います。

なので、ファイルをhtdocs内に設置するんじゃなく、エラーメッセージ通りにC:/MAMP/bin/mamp/のディレクトリの中にフォルダを作って配置してあげればいいんじゃないかと解決手段です。←本当の解決にはなってない

で、その方法で無事表示されたということです。

いつかapacheちゃんと勉強したいと思いました。

 

以前MySQLが起動しないというエラーも遭遇したのですが、そちらはMAMPを再インストールすることで解決できたので、とりあえずこれで開発自体は始められそうです。よかった。

コメント

タイトルとURLをコピーしました