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!