Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter dlefebvre68

    (@dlefebvre68)

    Well, I finally put my finger on it.

    Security feature in CentOS (SELinux). By default a connection to a remote SQL database from a web page is not permitted. This is to prevent an attacker who has gained some control over a web server to initiate a connection to a database on another host.

    That’s why I could connect from the command line and from a PHP script but not from a PHP script run from the web server.

    To fix this, you need to run :
    setsebool -P httpd_can_network_connect=1
    And that fixed it instantly. More details at http://stackoverflow.com/questions/4078205/php-cant-connect-to-mysql-with-error-13-but-command-line-can

    Thanks for all the suggestions. That made me enable audit logging in MySQL to realize that WordPress never made it to the DB server. That’s when I understood something was happening on the web server.

    Case closed.

    Thread Starter dlefebvre68

    (@dlefebvre68)

    @jon, yes absolutely. My wordpress is on websrv and the MySQL database is on dbsrv. From websrv I can run “mysql -u wp -h dbsrv -p wordpress” and once the password is entered I am connected to the right database on the right server.

    @catacaustic, those are my own servers that I run in my home lab for testing purposes.

    To make sure I was able to connect AND create tables (that’s what the setup process in WordPress does), I modified my test script and it can connect to the database on the db server and create a dummy table. So everything works as advertised. Except in WordPress.

    I’ll try to activate the logs in MySQL now to see if the problem is on that side.

    Thanks for all the pointers.

    Thread Starter dlefebvre68

    (@dlefebvre68)

    @marc, this is running in 2 VMs (CentOS 6.6 x86_64) on ESXi 5.1.

    @catacaustic, I don’t know which log files to look at exactly, so I enabled debug in WordPress and this is what I got:

    Warning: mysql_connect(): Can't connect to MySQL server on 'dbsrv' (13) in /var/www/html/wp-includes/wp-db.php on line 1372

    Where are the logs for WordPress? Excuse my ignorance.

    I will look at MySQL now.

    Thread Starter dlefebvre68

    (@dlefebvre68)

    By the way, dbsrv resolves to the correct IP address.

    Thanks for the help.

    Thread Starter dlefebvre68

    (@dlefebvre68)

    @marc,

    Yep, checked that about 500 times. I used hostname, FQDN, IP; same result. I checked for spaces in the different parameters, nothing wrong (unless I am looking with my “man’s eyes”).

    In fact here’s a snippet of the wp-config.php:

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');
    
    /** MySQL database username */
    define('DB_USER', 'wp');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'password');
    
    /** MySQL hostname */
    define('DB_HOST', 'dbsrv');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');

    I don’t get it.

Viewing 5 replies - 1 through 5 (of 5 total)