您的足迹:首页 > linux知识 >CentOS7 LNMP环境下phpmyadmin环境搭建

CentOS7 LNMP环境下phpmyadmin环境搭建

1.yum默认的库里是没有phpmyadmin的,我们需要从epel库里进行安装,之前已经安装过epel的朋友就可以直接下载rpm包了。
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
2.下载完成后安装phpmyadmin (默认安装在/usr/share/目录下)
yum install --enablerepo=remi --enablerepo=remi-php56 phpmyadmin  
3.然后,我们更改nginx的配置文件,添加phpmyadmin的路径。
vim /usr/local/nginx/conf/conf.d/default.conf
在nginx配置文件里加入以下代码。之后如下图所示。
??
 location /phpmyadmin {
        alias /usr/share/phpMyAdmin;
        index index.php;
    }

    location ~ /phpmyadmin/.+\.php$ {
        if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
            set $valid_fastcgi_script_name $1;
        }
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
    }
???
default.conf文件:
server {
        listen       80;
        server_name  localhost;
#add this begin
        large_client_header_buffers 4 16k;
        client_max_body_size 300m;
        client_body_buffer_size 128k;
        proxy_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        proxy_buffer_size 64k;
        proxy_buffers   4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
#add this end

        location / {
                root    /data/www/;
                index  index.html index.htm index.php;
                if (!-e $request_filename) {
# redirect server error pages to the static page /50x.html
#
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /usr/local/nginx/html;
        }
        location /phpmyadmin {
                alias /usr/share/phpMyAdmin;
                index index.php;
        }
        location ~ /phpmyadmin/.+\.php$ {
                if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
                set $valid_fastcgi_script_name $1;
                }
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9001; #端口要一致和php.ini
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
        }
        location ~ \.php {
                proxy_connect_timeout 600;
                proxy_read_timeout 600;
                proxy_send_timeout 600;
                root /data/www/;
                fastcgi_pass 127.0.0.1:9001;
                fastcgi_index index.php;
                include        fastcgi_params;

                set $path_info "";#定义变量 $path_info ,用于存放pathinfo信息
                set $real_script_name $fastcgi_script_name;#定义变量 $real_script_name,用于存放真实地址
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {#如果地址与引号内的正则表达式匹配
                        set $real_script_name $1;#将文件地址赋值给变量 $real_script_name
                        set $path_info $2;#将文件地址后的参数赋值给变量 $path_info
                }
#配置fastcgi的一些参数
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
        }
}

4.最后,我们打开浏览器,访问http://IP地址/phpmyadmin/,就会出现以下phpMyAdmin登录界面了

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)