nginx+php-fpm+phpmmyadmin setup php file does not work

Asked 2 years ago, Updated 2 years ago, 81 views

Thank you for your help.
This site is very helpful.Please let me know

Regarding the subject, I put nginx on CentOS 7 and ran the php file using php-fpm.
However, after setting up phpmyadmin and confirming communication, I accessed the php file again
"Access denied" appears, probably because I changed the nginx.conf configuration file a lot.
I think so.Also, no error.log in the path described in the nginx/nginx.log or html context was thrown up.

That's the flow.

Please let me know if there are any unnatural parts or other files to check.

environment:CentOS 7php 5.4
Configuration Status: Document Directory /etc/nginx/www
You can find test.php and html files in the above directory.

Here is an excerpt from the configuration file:
/etc/nginx/nginx.conf (I don't use default.conf)

server{
  listen80;
  Abbreviated.
  location / {
    root/etc/nginx/www;
    index index.html index.htm index.php
  }

  location~ ..php${
    fastcgi_param SCRIPT_NAME/etc/nginx/www$fast_cgi_script_name;
    fastcgi_param PATH_TRANSLATED/etc/nginx/www$fastcgi_path_info;
    fastcgi_pass unix: /var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  location/phpmyadmin {
    root usr/share;
    index index.php;

    location~^/phpmyadmin.+ ..php${
      fastcgi_pass unix: /var/run/php-fpm/php-fpm.sock;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_NAME/etc/nginx/www$fast_cgi_script_name;
      include fastcgi_params;
    }
  }
  Abbreviated.
}

/etc/php.ini

~Abbreviated.
cgi.fix_pathinfo=1
Abbreviated.

Because the phpmyadmin setting was not successful and I tried and tried,
I'm afraid I don't know how to change the settings.
I don't think it's possible to set permissions. I wonder if it's nginx.conf or php-fpm.
I'm thinking about it. I'm very worried and tired.

Thank you for your cooperation.

php nginx phpmyadmin

2022-09-30 21:13

1 Answers

(From Comment of Questioner)

Comment out fastcgi_param PATH_TRANSLATED and fastcgi_param SCRIPT_NAME was the wrong SCRIPT_FILENAME.

/etc/nginx/nginx.conf

server{

  ...

  location~ ..php${
    fastcgi_param SCRIPT_NAME/etc/nginx/www$fast_cgi_script_name;
   # fastcgi_param PATH_TRANSLATED/etc/nginx/www$fastcgi_path_info;###< - Comment out this line
    fastcgi_pass unix: /var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  location/phpmyadmin {
    root usr/share;
    index index.php;

    location~^/phpmyadmin.+ ..php${
      fastcgi_pass unix: /var/run/php-fpm/php-fpm.sock;
      fastcgi_index index.php;
     # fastcgi_param SCRIPT_NAME/etc/nginx/www$fast_cgi_script_name;###; - Not SCRIPT_NAME
      fastcgi_param SCRIPT_FILENAME/etc/nginx/www$fast_cgi_script_name;###<-SCRIPT_FILENAME
      include fastcgi_params;
    }
  }
  ...
}


2022-09-30 21:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.