基于nginx搭建phpmyadmin环境

1、将phpmyadmin安装下载,并解压;

2、在解压文件中复制config.sample.inc.php为config.inc.php,按服务器中mysql的情形进行配置;

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['connect_type'] = 'socket';
$cfg['Serers'][$i]['socket'] = '/tmp/mysqld.sock ';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysql if your server does not have mysqli */
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['AllowNoPassword'] = false;

以上信息可通过status查询;

3、创建存放log的文件夹及文件;

4、创建nginx集成phpmyadmin的配置文件:

server {
  listen 8081;
  server_name  localhost;
  access_log  /home/software/phpMyAdmin-4.0.10.9-all-languages/log/phpmyadmin-nginx.log  main;
  set $php_upstream 'unix:/home/workspace/odp3/var/php-cgi.sock';

  location / {
    root /home/software/phpMyAdmin-4.0.10.9-all-languages;
    index index.php;
  }

  location ~ \.php$ {
    root  /home/sunzhijie/software/phpMyAdmin-4.0.10.9-all-languages;
    fastcgi_pass   $php_upstream;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include		fastcgi_params;
  }

  location ~ /\.ht {
    deny  all;
  }
}
5、在nginx的配置文件中包含phpmyadmin的配置文件

include /home/sunzhijie/software/phpMyAdmin-4.0.10.9-all-languages/conf/phpmyadmin.conf;

6、重启nginx即可。

你可能感兴趣的:(PHP,Nginx)