Nginx php-fpm subdirectory
10,861
Solution 1
When you set location /pma
and root /var/www/default/phpMyAdmin
request http://server/pma/index.php
was search file /var/www/default/phpMyAdmin/pma/index.php
.
Use something like this:
location /pma/ {
rewrite /pma/ /phpMyAdmin/ last;
}
location /phpMyAdmin {
root /var/www/default/
try_files $uri =404;
index index.html index.php;
}
or rename /var/www/default/phpMyAdmin to /var/www/default/pma and change config to
location /pma {
root /var/www/default/
try_files $uri =404;
index index.html index.php;
}
Solution 2
Here is code that i'm using in nginx.
location /phpMyAdmin {
root /var/www/default;
index index.php index.html;
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/default$fastcgi_script_name;
include fastcgi_params;
}
}
Author by
Athlan
Updated on June 04, 2022Comments
-
Athlan almost 2 years
I want to run php-fpm via nginx, but for different locations I want to specify different roots:
for path:
http://localhost/ -> /usr/share/nginx/html http://localhost/pma -> /var/www/default/phpMyAdmin/ http://localhost/pga -> /var/www/default/phpPgAdmin/
My configuration doesn't work properly:
server { listen 80; server_name localhost; root /usr/share/nginx/html; try_files $uri =404; index index.php index.html; location / { } # redirect server error pages to the static page /40x.html # error_page 404 /404.html; location = /40x.html { } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { } location /pma { root /var/www/default/phpMyAdmin; try_files $uri =404; index index.html index.php; } location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
I always receive 404 error.