Nginx服务器上安装并配置PHPMyAdmin的教程
这篇文章主要介绍了Nginx服务器上安装并配置PHPMyAdmin的教程,附带一条PHPMyAdmin加载慢的解决方法:)需要的朋友可以参考下
一、 准备工作:
1. 如果mysql的root账号为空,需要设置root密码
CentOS下默认安装的mysql服务器,里面的root账号默认密码为空,首先为root设置一个密码
#mysqladmin -u root password yourpassword
*注: 虽然通过一些特殊配置,可以使phpmyadmin允许空密码登录,但是不推荐这样做,尤其是公网的服务器。
2. 设置php.ini正确配置session.save_path
1). 首先检查php.ini配置文件
#grep session.save_path /etc/php.ini
如果不存在以下设置,增加该配置。如果被注释了话,去掉注释
session.save_path = “/var/lib/php/session”
2). 查看该目录是否存在:
#ls /var/lib/php/session
如果不存在,则手工创建
#mkdir /var/lib/php/session
# 修改目录属主为nginx
chown nginx:nginx session/ -R
# 重启启动php-fpm
service php-fpm restart
二、安装配置phpmyadmin
1. 下载并解压到phpmyadmin
官方下载页面:
(中文用户应该选择下载all-languages版本)
下载完成后,解压:
unzip phpMyAdmin-4.1.12-all-languages.zip
移动到相应的目录位置,并改成容易访问的名称:
mv phpMyAdmin-4.1.12-all-languages /www/phpmyadmin
2. 配置phpmyadmin
复制一份配置文件:
#cd /www/phpmyadmin #cp config.sample.inc.php config.inc.php
配置config.inc.php
#vi config.inc.php
设置一个内部使用的秘钥(和内部加密有关,,与页面登录没有直接关系)
$cfg['blowfish_secret'] = ‘';
三、配置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; } }
重启nginx:
#service nginx restart
完成安装,访问:8081/,测试phpmyadmin。
四、phpmyadmin加载缓慢的解决方法
phpmyadmin4.0系列通通加载缓慢的最终原因是最近phpmyadmin的官网经常打不开,而phpmyadmin页面会自动检查官网上的程序 版本更新,所以当你进入phpmyadmin管理页面点击数据库的时候phpmyadmin一直在尝试连接官网从而把整个打开过程拖得很慢。
最终的解决办法是不让phpmyadmin检查更新,找到phpmyadmin目录下version_check.php文件,具体修改如下:
if (isset($_SESSION['cache']['version_check']) && time()
上面代码是通过注释掉else{......}中间这段来取消phpmyadmin连接官网version.json来检查更新
修改完后phpmyadmin马上又回到秒开了。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP
