使うdistributionはFedora43
x@fedora:~$ php -v
PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib64/php/modules/mysqli (/usr/lib64/php/modules/mysqli: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysqli.so (/usr/lib64/php/modules/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0
PHP 8.4.15 (cli) (built: Nov 18 2025 17:26:05) (NTS gcc x86_64)
Copyright (c) The PHP Group
Built by Fedora Project
Zend Engine v4.4.15, Copyright (c) Zend Technologies
with Zend OPcache v8.4.15, Copyright (c), by Zend Technologies
x@fedora:~$ which php
/usr/bin/php
x@fedora:~$ httpd -v
Server version: Apache/2.4.66 (Fedora Linux)
Server built: Dec 9 2025 00:00:00
x@fedora:~$ which httpd
/usr/bin/httpd
x@fedora:~$ mysql --version
mysql Ver 15.1 Distrib 10.11.13-MariaDB, for Linux (x86_64) using EditLine wrapper
x@fedora:~$
mariadb が入っていたようなので、削除!一応ストップさせてから。こうしないと、バッティングするのか、インストールは失敗する。
$ brew install mysql
...
...
==> Caveats
==> mysql
Upgrading from MySQL <8.4 to MySQL >9.0 requires running MySQL 8.4 first:
- brew services stop mysql
- brew install mysql@8.4
- brew services start mysql@8.4
- brew services stop mysql@8.4
- brew services start mysql
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
MySQL is configured to only allow connections from localhost by default
To connect run:
mysql -u root
To start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
/home/linuxbrew/.linuxbrew/opt/mysql/bin/mysqld_safe --datadir\=/home/linuxbrew/.linuxbrew/var/mysql
この終の部分が曲者で、必ずこれを打たないとダメ。
x@fedora:~$ mysql_secure_installation
Securing the MySQL server deployment.
Connecting to MySQL using a blank password.
VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: y
There are three levels of password validation policy:
LOW Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary file
Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.
New password:
Re-enter new password:
Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
これが出てくるという事は、ソケットが有るということか?よく分からないので、パスワードの他は全部 y でこれを済ませば、ログインできるはず。
x@fedora:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 9.5.0 Homebrew
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
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>
取り敢えず、wordpress ようのデータベースを作って、ctl+d で抜ける。
@fedora:~$ ls /tmp
mysql.sock
mysql.sock.lock
mysqlx.sock
mysqlx.sock.lock
...
...
ソケットがちゃんとある。
今度は、php http なんですが、fedora では初めから入っていてポート番号も違ってくるので、削除の必要なし。
$ brew install php
...
...
LoadModule php_module /home/linuxbrew/.linuxbrew/opt/php/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
これを、httpd.conf に追加してくれという意味に捉えて追加と言いたいが、この conf ファイルはどこにあるの?そこで、私は gnome-builder で探している。
起動して/home/linuxbrew を開くと空である。そこで表示オプションを右クリックで
無視したファイルを表示で、.linuxbrew が出てきて /etc 辺りを探すとある。
今回は珍しい、LoadModule で libphp.so がちゃんと入っている。
後は足りないところを追加。
この後、php をスタート!
x@fedora:~$ brew services start php
==> Successfully started `php` (label: homebrew.php)
同様に http も、と行きたいところですが、
/home/linuxbrew/.linuxbrew/opt/httpd/bin/httpd -D FOREGROUND &
[1] 11382
x@fedora:~$ AH00543: httpd: bad user name _www
そうかそこが ubuntu fedora と違って所有者が _www というユーザになっているのか。
linux は、apache か www-data である、ならば作らなければならない。一旦プロセスを止めて、
# useradd -M _www
# usermod -aG _www _www
確かこれでいいはず。
もう一度プロセスを起動
AH00558: httpd: Could not reliably determine the server's
fully qualified domain name, using fe80::7303:af2f:42c:547d%wlp3s0.
Set the 'ServerName' directive globally to suppress this message
ドメインに驚き!みたいなメッセージ、まあいっか。
httpd はやらなければならないメッセージは他にない
なのでスタートさせる。
a@fedora:~$ brew services start httpd
==> Successfully started `httpd` (label: homebrew.httpd)
a@fedora:~$ brew services list
Name Status User File
dbus none
emacs none
httpd none xxx
mysql none
php none xxx
podman none
unbound none
あれこれで動いてんだかなあ?
早速ブラウザーで確認!
localhost:8080
å‹•ã„ã¦ã‚‹ãžï¼It works!
It works!にはなっているけど最初の部分のちんぷんかんぷんな文字は何?
何か混じっていたか?ファイルを確認。
<html>
<head>
<title>It works! Apache httpd</title>
</head>
<body>
<p>動いてるぞ!It works!</p>
</body>
</html>
これでは日本語を表示しないらしい。
と言うか、これも初めてのケースで、index.php もあり、phpinfo() で確認できるようになっている。で気づいた、php.ini を直していなかった!ビルダーは起動させているので、早速、直そう!はい直しました。
そこで、wordpress の前に、phpmyadmin をインスールしてみた。
x@fedora:~$ brew install phpmyadmin
==> Fetching downloads for: phpmydmin
✔︎ Bottle Manifest phpmyadmin (5.2.3) [Downloaded 2.7KB/ 2.7KB]
✔︎ Bottle phpmyadmin (5.2.3) [Downloaded 14.5MB/ 14.5MB]
==> Pouring phpmyadmin--5.2.3.all.bottle.1.tar.gz
==> Caveats
To enable phpMyAdmin in Apache, add the following to httpd.conf and
restart Apache:
Alias /phpmyadmin /home/linuxbrew/.linuxbrew/share/phpmyadmin
<Directory /home/linuxbrew/.linuxbrew/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>
言われた通り Alias を追加、ブラウザで覗くと、 Not Found
そう書いてあるけど、再起動なのか?面倒だからここで、パソコン自体を再起動!
表示をして、ログインしようとしたら
> MySQL サーバにログインできません
> mysqli::real_connect(): (HY000/2002): No such file or directory
brew services list で確認するとmysql だけ none になっている。
mysql だけ手動なのか? start go!
httpd started xxx ~/.config/systemd/user/homebrew.httpd.service
mysql started xxx ~/.config/systemd/user/homebrew.mysql.service
php started xxx ~/.config/systemd/user/homebrew.php.service
やっとログインできた。
wordpress はダウンロードしたものを microsd に保存してあるのでドラッグドロップして解凍、後は一回やったことがあれば自ずと知れたものなので、省略。
無事ログインできました。
じゃあ、brew でやったほうが良いのか、普通に dnf からやった方が良いのか?
ですが、brew はメッセージが出てくるので、親切だと思うし、インストールするバージョンも brew が進んでいると思う。ubuntu でも何度か試しましたが、mysql でダメなので諦めモードです。と言うより、OS 自体が可笑しくなるので、お勧めできません。多分フォーマットが合わないんだろうと思います。今使っているマシンはMonterey までしか動かないマックです。しかも、Mac なのに brew は殆使えません。なので fedora にすり替えて、使っています。その操作性はまだ現役です。ということは、brew は、linux に最適のように思います。試すだけどうでしょうか。
後書き:
簡単に書きましたが、fedora なんか使ったことがない人にとっては、省略が多いと思います。御無礼仕(つかまつ)ります。