Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx change phpmyadmin folder name change error

i have my phpmyadmin setup as such

 location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }

i am looking to change the folder name so that i can access phpmyadmin through /secure

 location /secure {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/secure/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       fastcgi_index index.php;
                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                       include /etc/nginx/fastcgi_params;
               }
               location ~* ^/secure/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                       root /usr/share/;
               }
        }

but it keeps giving me 404 not found , any help would be appretiated guys thanks

like image 893
mega-crazy Avatar asked Apr 10 '26 07:04

mega-crazy


1 Answers

The below works and tested

location /pma/ {
    alias /usr/share/phpmyadmin/;
}

location ~ ^/pma/(.+\.php)$ {
    alias /usr/share/phpmyadmin/$1;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $request_filename;

    # From fastcgi_params
    include fastcgi_params;
    fastcgi_param  DOCUMENT_ROOT      /usr/share/phpmyadmin;
}

The key is to set the below

fastcgi_param  DOCUMENT_ROOT      /usr/share/phpmyadmin;

this is a variable that gets se in fastcgi_params but when to below it works like a charm change the 'pma' in both places to anything to u want and it'll work...no need for sym link

cheers

like image 168
mega-crazy Avatar answered Apr 12 '26 22:04

mega-crazy