Jump to content
  • 0

Firefox not connecting to SQL on LAMP server


Question

After installing CentOS 8 and using the instructions here on LinuxHint.com to install Sql, PHP, and Apache, I'm unable to make a connection from Firefox or Chrome to the SQL server.  Here are my installed versions:

CentOS Linux 8.1.1911
Apache 2.4.37
MariaDB 10.3.17
PHP 7.2.11
HeidiSQL 10.2.0.5599 (Windows Admin Client)

I'm using a private network - 192.168.5.0/24 with the server on 5.4 and using laptop for testing at 5.220.  Here is a .php file I'm using to test the connection from Firefox:

<?php
$link = mysqli_connect("192.168.5.4", "guardian", "green85", "bdstory");

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;

mysqli_close($link);
?>

Output of the /var/log/php-fpm/www-error.log file:

[23-Feb-2020 15:57:41 UTC] PHP Warning:  mysqli_connect(): (HY000/2002): Permission denied in /var/www/html/querytest.php on line 29

Now the crazy part is that from my Windows laptop and using HeidiSQL I am able to connect to the Mariadb and manage the databases, tables, and user.  But the PHP script in the browser does not.  I am completely stumped.  Any help and advice would be greatly appreciated.

Gene

 

 

 

 

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Hi Gene,

It may be because of SELinux. Can you set it to permissive mode and try to see if the script works?

To set SELinux to permissive mode temporarily, run the following command:

$ sudo setenforce 0

 

Then, you can run the following command to confirm whether the SELinux mode is changed to permissive mode.

$ sudo getenforce

 

Example:

image.png.0b243a9f3f320f4f4b56e771c271f9ef.png

 

 

If SELinux is causing the problem, then you will have to configure SELinux for the web root directory and its contents.

 

Wish you all the best.

Shovon

 

Link to post
Share on other sites
  • 0

Shovon,

Thanks for the reply.  I had shutdown the firewall:

FirewallD is not running

But did not think about SELinux.  Setting it to Permissive appears to have resolved my issue.  Since this is a totally private server for my sole development and testing I'll probably leave it that way.

Thanks again, Your article about installation of PHP, SQL, and Apache was very helpful.

Gene

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...