Issue
I have the following nginx config on my LEMP droplet:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html/public;
index index.php index.html index.htm;
server_name server_domain_or_IP;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I would like to run PHPMyAdmin together with Laravel on/phpmyadmin but only the Laravel routes get served to the browser. So any /phpmyadmin would be parsed as a route where it isn't one.
I have tried multiple things
Adding my own location
/phpmyadmin
above thelocation ~ \.php
even trying^~ /phpmyadmin
to force precedence.I've set my root to /usr/share/phpmyadmin, without any results.
I have tried copying the fastcgi options and basically copying the complete logic but using /phpmyadmin without any result either
I am pretty sure it's probably a small thing that I am missing.
Solution
The following code worked for me (added before the "location ~ \.php$ {
"-part:
location /phpmyadmin {
root /usr/share/nginx/html;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/nginx/html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
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/nginx/html;
}
}
Just make sure to adjust the three "root" locations to the folder where your "phpmyadmin" folder is in (the location of my phpmyadmin folder is here: "/usr/share/nginx/html/phpmyadmin"
Answered By - Christian Strang Answer Checked By - Terry (WPSolving Volunteer)