Reputation: 444
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 the location ~ \.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.
Upvotes: 4
Views: 5804
Reputation: 341
In our case, we used the following steps:
Created a location config at - /etc/nginx/conf.d/phpmyadmin.location
location ~* /dbmyadmin {
root /var/www;
index index.php;
location ~ ^/dbmyadmin/(.+\.php)$ {
root /var/www;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
include snippets/fastcgi-php.conf;
}
location ~* ^/dbmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /var/www;
}
}
And Included this config file into the default config file.
include /etc/nginx/conf.d/phpmyadmin.location;
Note: You can replace the PHP version and path as per your requirement.
Make sure you have created a short link of PHPMyAdmin directory to /var/www
directory with name dbmyadmin
ln -s /usr/share/phpmyadmin /var/www/dbmyadmin
Upvotes: 0
Reputation: 8530
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"
Upvotes: 17
Reputation: 221
Assuming your phpmyadmin configuration file is /etc/phpmyadmin/nginx-php5-fpm.conf
Try adding this to your nginx config before location{}:
include /etc/phpmyadmin/nginx-php5-fpm.conf;
add this into your phpmyadmin.conf
location /pma {
alias /usr/share/phpmyadmin/;
}
location ~ ^/pma/(.*\.(js|css|gif|jpg|png))$ {
alias /usr/share/phpmyadmin/$1;
}
location ~ ^/pma(.+\.php)$ {
alias /usr/share/phpmyadmin$1;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
charset utf8;
include fastcgi_params;
fastcgi_param DOCUMENT_ROOT /usr/share/phpmyadmin;
}
Your phpmyadmin will be accessible through http://yourdomain/pma
Enjoy !
Upvotes: 0