0

We recently decided to move our website from Apache2 and now we're trying to host a PHP website on our own Ubuntu 20.04 WSL server using NGINX and PHP7.2-FPM, but we're getting the following error:

FastCGI sent in stderr: "PHP message: PHP Warning: mysqli_connect(): (HY000/2002): Permission denied in /var/www/mysite/general/config.php on line 11" while reading response header from upstream, client: ::1, server: mysite.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "localhost"

In the config.php file, we're using the mysqli_connect function, which uses a user that can log in using the MySQL CLI just fine.

We're not using SELinux.

I've set up another page with the phpinfo() function, which seems to be working fine. It shows the mysqli extension is in fact loaded, so that shouldn't be the cause of the problem.

I'm using the www-data user in both the NGINX and PHP-FPM config files. Could this problem still have something to do with user permissions?

I've tried many solutions posted on similar problems, but nothing has worked so far. Let me know if you need more information and/or config files, thank you!

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • as far as I can tell, any network interaction should give the same error, like `file('https://google.com');` is it so? – Your Common Sense Jul 29 '22 at 13:14
  • Nope, that works just fine – Knoquer Bonk Jul 29 '22 at 13:20
  • Connect DATABASE Error TYPE: 2002: Permission denied doesn't answer my question either, I already stated I'm not using SELinux – Knoquer Bonk Jul 29 '22 at 13:21
  • Well then, if anyone will come up with a different answer, just ping me, I'll reopen this question. As of now, it looks like a duplicate. By the way, one doesn't 'use' selinix. It's just installed by default. – Your Common Sense Jul 29 '22 at 13:30
  • That's true, but I checked using the command and it isn't installed. getsebool -a | grep httpd returns: Command 'getsebool' not found, but can be installed with: apt install selinux-utils – Knoquer Bonk Jul 29 '22 at 13:43
  • Why WSL though? I never heard about a site hosted on WSL. It could be something with this unusual setup. – Your Common Sense Jul 29 '22 at 15:18

0 Answers0