SELinux causes PHP connection to MySQL exception solution for can ' t connect to MySQL server

Source: Internet
Author: User

Today's work encountered problems, the new Linux server, PHP, Apache and a series of extensions installed, in the local good program moved up to hold the database connection error, but with the SQL command can connect up,

Make a simple Judgment database Connection page or not, prove not a program problem, but the PHP where the problem, on the Internet to check the majority of days some methods are not the case after the accident found SELinux this thing

Check this out. Restricted access to external httpd;

Input command: Getsebool-a|grep-i httpd

There's going to be a httpd_can_network_connect---off of this stuff.

Off is equal to the permission to open httpd external access, to be set to on.

Method 1: Direct input command: Setsebool-p httpd_can_network_connect=1, re-command: Setenforce 0

Method 2:vim/etc/sysconfig/selinux

There's a line #SELINUX =enforcing instead: selinux=disabled, re-order: Setenforce 0

SELinux causes PHP connection to MySQL exception solution for can ' t connect to MySQL server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.