phpMyAdminもSSL化した。
ついでに、少しNginxの設定を変更した。設定の追加、変更は以下のサイトを参考にした。
- nginx+php-fpmの構成でphpMyAdminをインストール(nginxの設定) | ハックノート
- How to Install phpMyAdmin with Nginx, MariaDB, PHP7 on Ubuntu 16.04
- CentOS 6にnginxとphpMyAdmin最新バージョンをサクッとインストールする方法 – Will feel Tips
それぞれの記事に載っていたNginxのconfファイルは以下の通り。
server {
listen 8080;
server_name localhost;
index index.php;
location /phpMyAdmin {
alias /usr/share/phpMyAdmin/;
index index.php index.html;
location ~ ^/phpMyAdmin/(.+\.php)$ {
alias /usr/share/phpMyAdmin;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$1;
include fastcgi_params;
fastcgi_intercept_errors on;
allow all;
}
}
}
location /phpmyadmin {
root /usr/share/;
index index.php;
try_files $uri $uri/ =404;
location ~ ^/phpmyadmin/(doc|sql|setup)/ {
deny all;
}
location ~ /phpmyadmin/(.+\.php)$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
}
server {
###### 中略 ######
location /phpMyAdmin {
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
if ($uri ~ \.(gif|jpg|png|ico|js|css)$) {
access_log off;
}
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
location ~ /phpMyAdmin/.*\.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
追加したのは、BASIC認証の部分、アクセスログのところ、docディレクトリなどへのアクセス禁止あたり。
また、ずーと、このエラー表示が出ていたので、対策した。
設定ファイルに、暗号化 (blowfish_secret) 用の非公開パスフレーズの設定を必要とするようになりました。
phpMyAdmin 環境保管領域が完全に設定されていないため、いくつかの拡張機能が無効になっています。理由についてはこちらをご覧ください。
代わりにデータベースの操作タブを使って設定することもできます。
実際にした作業は、紆余曲折あって、こうなりました。
- phpMyAdminのディレクトリにあるconfig.inc.phpで、blowfish_secretを設定 → 反映されない
- /etc/phpMyadmin/config.inc.phpで設定 → 反映されない
- /var/lib/phpMyAdmin/config.inc.phpで設定 → 反映されない
- phpMyAdminをいったん削除(yum remove phpMyAdmin)
- /usr/share/phpMyAdmin、/etc/phpMyAdmin、/var/lib/phpMyAdminを全削除
- phpMyAdminを再度インストール(yum install phpMyAdmin –enablerepo=remi)
- /etc/phpMyAdminのパーミッションを変更(chown -R root.nginx /etc/phpMyAdmin)
- /var/lib/phpMyAdminのパーミッションを変更(chown -R nginx.nginx /var/lib/phpMyAdmin)
これで、blowfish_secretの問題は解決。
環境保管領域の確保のため、create_tables.sqlをインポートしてみるが、なぜか読み込めない。ということで、結局MariaDBを再インストール。
yum remove mariadb yum install MariaDB yum install MariaDB-*
MariaDBを再起動して、create_tables.sqlをインポートしたら、あっさり読み込めた。
コメント