http://test.com looks onto ip 222.222.222.222
Server system: Gentoo Base System release 1.12.13
Script for connect:
$connection = new \mysqli('111.111.111.111', 'user', 'password', 'db');
if (mysqli_connect_error()) {
echo "Error: {$connection->connect_error}";
}
else {
echo "Server Info: {$connection->server_info}";
}
When I'm trying to open in browser "http://test.com/test.php", I get:
Error: Can't connect to MySQL server on '111.111.111.111' (13)
... but when I'm starting this script from command line on the server 222.222.222.222, I have another result:
/usr/bin/php /var/www/reporter/test.php
Server Info: 5.5.14-enterprise-commercial-advanced-log
Directly connection from command line also correct:
mysql -h 111.111.111.111 -u user -p -P 3306
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 25236357
Server version: 5.5.14-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Answer
Problem with client's environment - Selinux in Centos. Command fo fix it:
setsebool -P httpd_can_network_connect=1
Problem with client's environment - Selinux in Centos. Command fo fix it:
setsebool -P httpd_can_network_connect=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With