白森 发表于 2019-2-15 13:16:49

CentOS 7服务器上使用Nginx+phpMyAdmin

  1,在CentOS7安装epel源,(原服务器上要有php环境以及php的进程管理器php-fpm)
  yum-y install epel-release
  2,安装phpMyAdmin软件
  yum-y install phpmyadmin
  3,为了使Nginx Web服务器正确地查找和提供phpMyAdmin文件,我们只需要创建一个从安装文件到我们的Nginx文档根目录的符号链接:
  ln -s /usr/share/phpMyAdmin /usr/share/nginx/html
  4,配置nginx,如下图
http://i2.运维网.com/images/blog/201812/25/020e45d68b781ebde975fa612b72c88c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=
  5,重新启动我们的PHP处理器,以确保它可以加载我们安装的额外的PHP模块:
  systemctl restart php-fpm
  6,这样,我们的phpMyAdmin安装现在可以运行。 要访问该界面中,转至服务器的域名或公网IP地址,后跟/phpMyAdmin ,在网页浏览器
  http://server_domain_or_IP/phpMyAdmin
http://i2.运维网.com/images/blog/201812/25/01e9db25c25bb1ff396558f5d63e9830.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=
  7,我们可以授权我们的mysql数据库服务器对外远程访问
  登录mysql数据库
  msyql    -uyourusername-pyoupassword

  mysql> grant all privileges on .   toyourMysqlUser@'%' >  mysql> flush privileges;
  mysql> exit;
  8,测试并验证
  9,若是有多个需要连接的数据库,可以修改phpMyAdmin的配置文件,修改根目录/etc/phpMyAdmin中的config.inc.php配置
  $i = 0;
  /*

[*]服务器A  /
  $i++;
  / Authentication type */
  $cfg['Servers'][$i]['auth_type'] = 'config';
  $cfg['Servers'][$i]['host'] = '127.0.0.1';
  $cfg['Servers'][$i]['port'] = '3307';
  $cfg['Servers'][$i]['connect_type'] = 'tcp';
  $cfg['Servers'][$i]['compress'] = false;
  $cfg['Servers'][$i]['extension'] = 'mysqli';
  $cfg['Servers'][$i]['user'] = 'root';
  $cfg['Servers'][$i]['password'] = '123456';
  $cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
  $cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
  $cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
  $cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
  /*

[*]服务器B  */
  $i++;
  $cfg['Servers'][$i]['auth_type'] = 'config';
  $cfg['Servers'][$i]['host'] = '127.0.0.1';
  $cfg['Servers'][$i]['port'] = '3308';
  $cfg['Servers'][$i]['connect_type'] = 'tcp';
  $cfg['Servers'][$i]['compress'] = false;
  $cfg['Servers'][$i]['extension'] = 'mysqli';
  $cfg['Servers'][$i]['user'] = 'root';
  $cfg['Servers'][$i]['password'] = ‘123456';
  $cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
  $cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
  $cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
  $cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
  /*

[*]服务器C  */
  $i++;
  $cfg['Servers'][$i]['auth_type'] = 'config';
  $cfg['Servers'][$i]['host'] = '127.0.0.1';
  $cfg['Servers'][$i]['port'] = '3306';
  $cfg['Servers'][$i]['connect_type'] = 'tcp';
  $cfg['Servers'][$i]['compress'] = false;
  $cfg['Servers'][$i]['extension'] = 'mysqli';
  $cfg['Servers'][$i]['user'] = 'root';
  $cfg['Servers'][$i]['password'] = '123456';
  $cfg['Servers'][$i]['bs_garbage_threshold'] = 50;
  $cfg['Servers'][$i]['bs_repository_threshold'] = '32M';
  $cfg['Servers'][$i]['bs_temp_blob_timeout'] = 600;
  $cfg['Servers'][$i]['bs_temp_log_threshold'] = '32M';
  保存,打开phpmyadmin,在首页就可以看到服务器列表了
  10,可参考内容如下
  https://www.howtoing.com/how-to-install-and-secure-phpmyadmin-with-nginx-on-a-centos-7-server

页: [1]
查看完整版本: CentOS 7服务器上使用Nginx+phpMyAdmin