I
I
Ilia Malashko2020-02-29 09:42:45
PHP
Ilia Malashko, 2020-02-29 09:42:45

How to properly configure access to phpmyadmin (nginx+php-fpm)?

Hello.

Server on Ubuntu. Hosts are configured on nginx + php7.2-fpm I configured the domain, forwarded the symlink sudo ln -s /usr/share/phpmyadmin /var/www/8991.ru/
to the directory with the site When switching to 8991.ru, it gives php, but when switching on 8991.ru/phpmyadmin error "No input file specified". The logs also show a problem with permissions:

[email protected]:~$ sudo cat /var/log/nginx/error.log
2020/02/29 07:08:55 [error] 5202#5202: *131 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/usr/share/phpmyadmin/index.php) is not within the allowed path(s): (/var/www/) in Unknown on line 0
PHP message: PHP Warning:  Unknown: failed to open stream: Operation not permitted in Unknown on line 0
Unable to open primary script: /var/www/8991.ru/public_html/phpmyadmin/index.php (Operation not permitted)" while reading response header from upstream, client: 90.189.152.143, server: 8991.ru, request: "GET /phpmyadmin/ HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:", host: "8991.ru"

I understand that the problem is related to the rights, but I don’t understand where and to whom the rights need to be given.
For /usr/share/phpmyadmin/ I tried to assign the owner of www-data and the owner of the site directory 8991.ru
Where else should I check the rights?

nginx config:
server {
listen 80;
#root /usr/share/nginx/8991.ru;
root /var/www/8991.ru/public_html/;
index index.php index.html index.htm;
server_name 8991.ru www.8991.ru;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm-8991.sock;
include snippets/fastcgi-php.conf;
}
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-03-02
@Jewish_Cat

your symlink will not work correctly. Nginx thinks it's a file, not a folder.
Try adding this

location /phpmyadmin/ {
    alias /usr/share/phpmyadmin;
    try_files $uri $uri/ /index.php;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question