When I try accessing MySQL from my webpage, I get a blank screen. I can access mysql from my terminal no problem.
I checked my /var/log/httpd/error_log and the following errors appear when I try accessing the webpage
PHP Warning: mysql_pconnect(): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (13)
in /var/www/html/shenlab/Connection/connShen.php on line 9, referrer: http://shenlab.sols.unlv.edu/shenlab/
PHP Fatal error: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (13) in
/var/www/html/shenlab/Connections/connShen.php on line 9, referrer: http://shenlab.sols.unlv.edu/shenlab/
The php file
/var/www/html/shenlab/Connection/connShen.php has the following code
$hostname_connShen = "localhost";
$database_connShen = "shenlab";
$username_connShen = "wrkydb";
$password_connShen = "notshownforsecurity";
$connShen = mysql_pconnect($hostname_connShen, $username_connShen, $password_connShen) or trigger_error(mysql_error(),E_USER_ERROR);
I tried changing the hostname as follows but neither worked
$hostname_connShen = "127.0.0.1";
$hostname_connShen = "localhost:/data1/mysql/mysql.sock";
The /etc/my.cnf contains the following
# Disabling symbolic-links is recommended to prevent assorted security risks
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd
socket = /data1/mysql/mysql.sock
I also tried setting the following booleans but no luck
# setsebool httpd_can_network_connect_db 1
# setsebool httpd_can_network_connect 1
The only thing that seems to work is turning off selinux with "setenforce 0".
Once I turn off selinux, the web page works perfectly. When I turn it back on, the web page goes blank.
Turning off selinux is not an option for me.
If anyone has something else for me to try, it would be greatly appreciated.
Thanks in advance.