LoginSignup
0
0

More than 3 years have passed since last update.

【超ド級初心者用】MacでphpMyAdminを使えるように

Posted at

実現したかったこと

当方、超ド級のMac初心者かつphp初心者。非エンジニアです。勉強中です。ApacheやHomebrewなどの仕組みがいまいちわかっていないせいか、サイトに書いてあることを参考にやっても全然表示されずに途方にくれました。丸2日もかかったしまったことを書いておきます。

MacBookでphpMyAdminをブラウザで表示できるようにしたいのですが、いろんなサイトを真似してやってもうまくいきません。

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

アドレスバーにlocalhostを入力するとIt works!は表示されます。

phpMyAdminをHomebrewでインストールしました。

chromeのアドレスバーにphpMyAdmin.local:8080やlocalhost/phpMyAdminを入力してもログイン画面が出てこず、下記のように表示されます。

Not Found
The requested URL was not found on this server.

Apacheのエラーログを見ると
/private/var/log/apache2/error_log

[Fri Jul 10 14:49:48.931992 2020] [core:notice] [pid 39120] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'

MySQLの設定

以下を参考に設定しました。
https://tofusystem.work/programming-lesson/howto-mysql-phpmyadmin-setting-for-mac/

$ mysql --version
mysql  Ver 8.0.19 for osx10.15 on x86_64 (Homebrew)

インストールはできているかと。

$ mysql.server start
Starting MySQL
 SUCCESS! 

2020-07-10T07:02:12.6NZ mysqld_safe A mysqld process already exists

MySQLを起動するとSUCCESS!が表示されますが、続いて最後の一行も出てきます。この時点であかん気はしていますが、とりあえず起動できているものとして次のMySQLの設定に進みました。

MySQLはrootパスワード無しでインストールされます。
下記コマンドでrootパスワードなどの初期設定をしましょう。
途中でyesまたはnoで答える部分があるので、それについても記載しています。
基本的にはyesまたはYで答えればOKです。

これに従い設定しました。

MySQLにログインも成功しているようです。

$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.19 Homebrew

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

続いてhomebrewでphpmyadminをインストール。インストール時に次のようなメーセージが出てくるのでそれに従い瀬一定するとのことだったので、やってみました。httpd.confが見当たらなかったので、https://qiita.com/yukibe/items/8896a91007cc5a1dfc45を参考にしました。

引用テキストadd this at the end of
your /etc/apache2/httpd.conf for instance) :

ということで、上のディレクトリにhttpd.confが見つかったので、最後の行に以下のAlias〜をコピーして貼り付けしました。

==> Caveats
To enable phpMyAdmin in Apache, add the following to httpd.conf and
restart Apache:
    Alias /phpmyadmin /usr/local/share/phpmyadmin
    <Directory /usr/local/share/phpmyadmin/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        <IfModule mod_authz_core.c>
            Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            Order allow,deny
            Allow from all
        </IfModule>
    </Directory>
Then open http://localhost/phpmyadmin
The configuration file is /usr/local/etc/phpmyadmin.config.inc.php

上記の表示によルトこれでApacheを再起動すればphpMyAdminがブラウザから表示されるはず?!

$ sudo apachectl restart

なのに表示されない・・・

と思ったら表示されました。
書きながら手順通りにもう一度やっていたらできてしまいました。

何が原因だったのかもわからないけど、とりあえずできたのでOKですかね。

初心者にはよくある現象ですかね。同じようにやっているつもりでもどこかでミスをしていたのでしょう。こういうことが私自身はよくあるのでとりあえず記録として残して置くことが重要ですね。

他にも同じように困っている人の参考になればと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0