Database exists with username & password; Blank page on Website

VPS OS is: CentOS Linux release 7.8.2003 (Core)
2 Core CPU
2 GB RAM
20 GB disk space

When I stop MySQL, I get this kind of error:

Database error

Could not connect to the MySQL database. The forum is probably not installed yet.
MySQL error message: Access denied for user ‘dbuser_user’@‘localhost’ (using password: YES)

When I start MySQL, I get a blank page on the website.
A test user connection script is also showing that DB user and DB password are connected. I have uploaded the database via Putty. I can see it via phpMyAdmin.
I have assigned database to the user and ALL permissions have been given.

The website had been running elsewhere in a regular Linux cPanel environment without any such issue.
For some reason I cannot share the website URL publicly.

Please advise what am I missing here.

The blank page does not necessarily indicate that there is a problem with the connection to the db.

What do your Apache / nginx error logs say?

#1

mysqli_connect(‘host’, ‘db_user’, ‘db_pass’) or die(‘Could not connect the database : Username or password incorrect’);
mysqli_select_db(‘db_name’) or die (‘No database found’);
echo ‘Database Connected successfully’;

The above shows me: No database found

#2

FROM: /var/log/virtualmin/_error_log

The following is related to the website forum script.

[Sun Nov 15 22:21:12.182358 2020] [fcgid:warn] [pid 20593] [client 1.2.3.4:10340] mod_fcgid: stderr: PHP Fatal error: Uncaught → Smarty: unable to write file /home/vinayy/public_html/templates_c/wrt5fb15c802c73d0_97074824 ←
[Sun Nov 15 22:21:12.182395 2020] [fcgid:warn] [pid 20593] [client 1.2.3.4:10340] mod_fcgid: stderr: thrown in /home/vinayy/public_html/modules/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 59
[Sun Nov 15 22:21:15.904379 2020] [fcgid:warn] [pid 20607] [client 1.2.3.4:14792] mod_fcgid: stderr: PHP Fatal error: Uncaught → Smarty: unable to write file /home/vinayy/public_html/templates_c/wrt5fb15c83dcba34_14116931 ←
[Sun Nov 15 22:21:15.904416 2020] [fcgid:warn] [pid 20607] [client 1.2.3.4:14792] mod_fcgid: stderr: thrown in /home/vinayy/public_html/modules/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 59
[Sun Nov 15 22:21:41.614149 2020] [fcgid:warn] [pid 20577] [client 1.2.3.4:23908] mod_fcgid: stderr: PHP Fatal error: Uncaught → Smarty: unable to write file /home/vinayy/public_html/templates_c/wrt5fb15c9d95deb9_88749586 ← , referer: https://www.google.com/
[Sun Nov 15 22:21:41.614203 2020] [fcgid:warn] [pid 20577] [client 1.2.3.4:23908] mod_fcgid: stderr: thrown in /home/vinayy/public_html/modules/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 59, referer: https://www.google.com/
[Sun Nov 15 22:22:13.164057 2020] [fcgid:warn] [pid 2923] [client 1.2.3.4:63434] mod_fcgid: stderr: PHP Fatal error: Uncaught → Smarty: unable to write file /home/vinayy/public_html/templates_c/wrt5fb15cbd27fce7_48182875 ←
[Sun Nov 15 22:22:13.164091 2020] [fcgid:warn] [pid 2923] [client 1.2.3.4:63434] mod_fcgid: stderr: thrown in /home/vinayy/public_html/modules/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 59
[Sun Nov 15 22:22:18.818527 2020] [fcgid:warn] [pid 20582] [client 1.2.3.4:13852] mod_fcgid: stderr: PHP Fatal error: Uncaught → Smarty: unable to write file /home/vinayy/public_html/templates_c/wrt5fb15cc2c7c5a5_18106273 ←
[Sun Nov 15 22:22:18.818560 2020] [fcgid:warn] [pid 20582] [client 1.2.3.4:13852] mod_fcgid: stderr: thrown in /home/vinayy/public_html/modules/smarty/sysplugins/smarty_internal_runtime_writefile.php on line 59

The above-mentioned line 59 is:

throw new SmartyException(“unable to write file {$_tmp_file}”);

Could all the errors be due to the database not being accessible?
Or has it got something to do with mod_fcgid?

No, I see no db related entries in the error log. The issue is due to some other reason.

Smarty writes cache and this cache directory (templates_c) must be writable.

1 Like

Thanks, it is working now but I had to change the permission of templates_c folder to 777. Whereas, in my previous hosting it worked with the permission 771.

I feel it should not be 777. Please advise.

Before seeking this help here, I had deleted the website and set it up again. And with your suggestion it is working now, even with 771 permission. I hope 771 isn’t much risky.

I am sorry for writing again and again but the website’s full (normal) functionality is restored only when the permission of cache directory (templates_c ) is set to 777. What do I need to do to make it work with 770 permission?

I have now set the group and owner to the website username and the permission to 770 of the cache directory (templates_c ) and it seems to be working.

Good to know.

1 Like