phpmyAdmin的nginx 配置
平时工作中用mysql做数据库后,经常需要查看表结构,修改表结构,做一些查询, 在linux的laptop或者工作机上缺少一个趁手的mysql UI工具, 查了下用phpmyAdmin来做这个。
但是大多数文章都是用apache来做phpMyAdmin的web服务器, 而我机器上已经有了nginx,应该可以使用它来做, 翻了些文章最后实现如下。
下载phpMyAdmin
https://www.phpmyadmin.net/
安装 nginx
sudo apt install nginx
or
sudo yum install nginx
配置nginx
server {
listen 8090;
root /usr/share/phpmyadmin/;
index index.php index.html index.htm index.nginx-debian.html;
access_log /var/log/nginx/phpmyadmin_access.log;
error_log /var/log/nginx/phpmyadmin_error.log;
location / {
index index.php index.html index.htm;
location ~ ^/(.+\.php)$ {
try_files $uri =404;
root /usr/share/phpmyadmin/;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
location ~* ^/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/phpmyadmin/;
}
}
}
注意
root /usr/share/phpmyadmin/;
这行配置到你下载的phpmyadmin解压后的地方,该地方应该有index.html
重启nginx
sudo nginx -s reload
远程连接mysql问题解决
- 碰到 error: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in…
解决:
ALTER USER ‘mysqlUsername’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘mysqlUsernamePassword’;
引自 stackoverflow