CentOS8にphpMyAdminをインストールした話
自室にステージング用のサーバを立てることに
WordPressとかのソースを触るときに,いちいちバックアップとかなんやかんやがめんどくさいので,ステージング環境を作ってしまおうって話.
phpMyAdminのインストールで詰まった.
何度やっても,
エラー: 一致するものが見つかりません: phpMyAdmin
でインストールできない.
そんな訳あるかといいながら頑張った結論.
無理
あー,"まだCentOS8のリポジトリにphpMyAdmin入れてないから公式Webから落として."って書いてる. CentOS8の情報はまだまだ新しいので,"CentOS phpMyAdmin"とかじゃ引っかからなくてめっちゃ悩んだ.
ざっくりやったこと書く
わからなければ聞いてください.
リポジトリ
# yum install epel-release # yum install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
入れなくてもイイかも.試行錯誤したので両方入れたけど.
とりあえずMariaDBから入れる
# yum -y install mariadb-server # nano /etc/my.cnf.d/mariadb-server.cnf
これ,CentOS7の記事とパスが違った.
で,[mysqld]の項目に
character-set-server = utf8
を追記.
# systemctl start mariadb # systemctl enable mariadb # mysql_secure_installation
ここの設定は下記の参考サイト様一覧の,"データベースサーバー構築(MariaDB)"を見てください.
"MariaDB初期設定"の項目と"MariaDB確認"の途中まで終わらせればOKかも.
All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
でインストール完了.
# mysql -u root -p MariaDB [(none)]> create database test(作りたいデータベース名); MariaDB [(none)]> exit
これでデータベースの準備はOK.
phpと周辺のモン入れる
# yum install -y wget php php-pdo php-pecl-zip php-json php-common php-fpm php-mbstring php-cli php-mysqlnd
本題のphpMyAdmin
# wget https://files.phpmyadmin.net/phpMyAdmin/4.9.1/phpMyAdmin-4.9.1-all-languages.tar.gz # tar -zxvf phpMyAdmin-4.9.1-all-languages.tar.gz # mv phpMyAdmin-4.9.1-all-languages /usr/share/phpMyAdmin # cp -pr /usr/share/phpMyAdmin/config.sample.inc.php /usr/share/phpMyAdmin/config.inc.php
次に,ここにアクセスして phpMyAdmin blowfish secret generator
文字列のとこを引っ張ってくる.
# nano /usr/share/phpMyAdmin/config.inc.php
で
$cfg['blowfish_secret'] = 'ここにコピーした文字列を入れる'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
ここで,私は本番環境からデータベースをエクスポートしまして,
# mysql test(さっき作成したデータベース名) < インポートするファイル名.sql -u root -p
これでローカルにデータベースを入れれました.
まだ続きます.
# nano /etc/httpd/conf.d/phpMyAdmin.conf
で多分新規作成ファイルなので,白紙の状態に下のやつを貼り付け.
Alias /phpMyAdmin /usr/share/phpMyAdmin Alias /phpmyadmin /usr/share/phpMyAdmin <Directory /usr/share/phpMyAdmin/> AddDefaultCharset UTF-8 <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory> <Directory /usr/share/phpMyAdmin/setup/> <IfModule mod_authz_core.c> # Apache 2.4 <RequireAny> Require all granted </RequireAny> </IfModule> <IfModule !mod_authz_core.c> # Apache 2.2 Order Deny,Allow Deny from All Allow from 127.0.0.1 Allow from ::1 </IfModule> </Directory>
次に,
# mkdir /usr/share/phpMyAdmin/tmp # chmod 777 /usr/share/phpMyAdmin/tmp # chown -R apache:apache /usr/share/phpMyAdmin # systemctl restart httpd
SELinuxの設定もいるみたいなので,続いて
# yum install -y policycoreutils-python-utils (インストール済みやと思われる) # semanage fcontext -a -t httpd_sys_rw_content_t '/usr/share/phpMyAdmin/' # semanage fcontext -a -t httpd_sys_rw_content_t "/usr/share/phpMyAdmin/tmp(/.*)?" # restorecon -Rv '/usr/share/phpMyAdmin/'
Firewallの設定は自分はしてあったのでパス.
# firewall-cmd --permanent --add-service=http # firewall-cmd --reload
ほんだらphpMyAdminにアクセスできるように!
http://ipアドレスやらlocalhostやら/phpMyAdmin
ユーザ作成してなけりゃユーザ名はroot.ログインすると,test(さっき作ったやつ)って名前でデータベースが作られているはずです!