I am having issues with my phpmyadmin on my nginx install.
When I enter <ServerIP>/phpmyadmin
and logs in, I get redirected to <ServerIP>/index.php?<tokenstuff>
instead of <ServerIP>/phpmyadmin/index.php?<tokenstuff>
Nginx config file:
user nginx;
worker_processes 5;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 2;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
Default.conf:
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
try_files $uri =404;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
}
(Any general tips on tidying op those config files are accepted too)
Even though the author has solved his problem reinstalling phpMyAdmin, nginx needs to be properly configurated to handle the redirect upon login correctly.
After days smashing my head on the keyboard I finally found the real solution and I'm sharing here as this thread still have high priority on google search.
As stated on the link : http://www.samundra.com.np/use-phpmyadmin-with-nginx-and-php7/1374
To solve the problem, you should add the following block of code to your nginx default site-available, you will access it with :
Place this block in
server
block:I hope this helps someone one day...
This problem is caused by the common configuration of cgi.fix_pathinfo = 0 that disables the current path for PHP-FPM. One quick solution is to change cgi.fix_pathinfo back to 1, or set the path parameters on the virtual server block of nginx.
You're problem seems to be similar to this: https://stackoverflow.com/questions/1011101/nginx-location-directive-doesnt-seem-to-be-working-am-i-missing-something
If by reading that and changing you're config you still have problems please do tell!
This doesn't sound like an nginx issue. This sounds like phpMyAdmin wasn't installed correctly and thinks that it is at
/
instead of/phpmyadmin
. Check your phpMyAdmin configuration.open:
add:
see:
https://docs.phpmyadmin.net/en/latest/config.html#basic-settings
.
add a virtaul host to your lamp server with any domain name like phpmyadmin1.com
Edit your Hosts file
add this line at bottom
save and close, then restart your server
Access your virtual host url on browser your see phpmyadmin login page
http://screencloud.net/v/nGK5
http://screencloud.net/v/6M8r
Only this worked for me
phpMyAdmin from repositories of Ubuntu 16.04 and later don't properly redirect.
I'm just download new version of phpmyadmin from official phpmyadmin site:
open config.inc.php:
and put some random character berween '
save and open your domain/phpmyadmin in browser
also you can change link to phpmyadmin (for better security) and add basic auth from nginx to link:
now your phpmyadmin work on https://domain/anything, lets add some password:
now open your nginx config (by default: sudo nano /etc/nginx/sites-available/default) and add befor last }
Enable Configuration Storage:
Locate following lines:
Change to:
Locate:
Uncomment them ( remove // )
Now save and exit.
Go to your mysql (by default: sudo mysql -u root -p)
now try to open domain/anything in browser