Home >Backend Development >PHP Tutorial >Tutorial to install and configure PHPMyAdmin on Nginx server_php tips

Tutorial to install and configure PHPMyAdmin on Nginx server_php tips

WBOY
WBOYOriginal
2016-05-16 20:08:181059browse

1. Preparation:

1. If the root account of mysql is empty, you need to set the root password
The mysql server installed by default under CentOS, the default password of the root account inside is empty, first set a password for root
#mysqladmin -u root password yourpassword

*Note: Although phpmyadmin can allow empty password login through some special configurations, this is not recommended, especially for public network servers.

2. Set php.ini to correctly configure session.save_path

1). First check the php.ini configuration file

#grep session.save_path /etc/php.ini

If the following settings do not exist, add this configuration. If it is commented, remove the comment

session.save_path = “/var/lib/php/session”

2). Check whether the directory exists:

#ls /var/lib/php/session

If it does not exist, create it manually
#mkdir /var/lib/php/session

# Change the directory owner to nginx

chown nginx:nginx session/ -R

# Restart php-fpm

service php-fpm restart

2. Install and configure phpmyadmin

1. Download and extract to phpmyadmin
Official download page: http://www.phpmyadmin.net/home_page/downloads.php
(Chinese users should choose to download the all-languages ​​version)

After downloading is complete, unzip:

unzip phpMyAdmin-4.1.12-all-languages.zip

Move to the appropriate directory location and change it to an easily accessible name:

mv phpMyAdmin-4.1.12-all-languages /www/phpmyadmin

2. Configure phpmyadmin

Copy a configuration file:

#cd /www/phpmyadmin
#cp config.sample.inc.php config.inc.php

Configure config.inc.php
#vi config.inc.php

Set a secret key for internal use (related to internal encryption, not directly related to page login)

$cfg['blowfish_secret'] = ‘www.tudaxia.com';

3. Configure the site under Nignx

vi /etc/nginx/conf.d/phpmyadmin.conf

server {
 listen 8081;
 server_name localhost;
 access_log /var/log/nginx/phpmyadmin-access.log main;

 location / {
  root /www/phpmyadmin;
  index index.php;
 }

 location ~ \.php$ {
  root /www/phpmyadmin;
  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;
 }

 location ~ /\.ht {
  deny all;
 }
}

Restart nginx:

#service nginx restart

Complete the installation, visit http://yourserver:8081/ and test phpmyadmin.

4. Solution to slow loading of phpmyadmin


The final reason for the slow loading of the phpmyadmin4.0 series is that the official website of phpmyadmin often cannot be opened recently, and the phpmyadmin page will automatically check the program version update on the official website, so when you enter the phpmyadmin management page and click on the database, phpmyadmin has been trying to connect to the official website. This slows down the entire opening process.

The final solution is to prevent phpmyadmin from checking for updates. Find the version_check.php file in the phpmyadmin directory and modify it as follows:

if (isset($_SESSION['cache']['version_check'])
  && time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6
) {
  $save = false;
  $response = $_SESSION['cache']['version_check']['response'];
} else {
//  $save = true;
//  $file = 'http://www.phpmyadmin.net/home_page/version.json';
//  if (ini_get('allow_url_fopen')) {
//    $response = file_get_contents($file);
//  } else if (function_exists('curl_init')) {
//    $curl_handle = curl_init($file);
//    curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
//    $response = curl_exec($curl_handle);
//  }
}

The above code is to cancel phpmyadmin's connection to the official website version.json by commenting out the middle section of else{......} to check for updates

After the modification, phpmyadmin immediately returned to open in seconds.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn