MySQL connection parameters belong in environment variables, not source code. On Amazon Linux (CentOS), the apache user has no home directory, so there’s no .profile to set them. Workaround: use Apache environment variables.
Step 1: create /etc/httpd/conf.d/wp_mysql.conf and set the connection parameters. Files in /etc/httpd/conf.d are parsed automatically by Apache.
SetEnv WP_DB_NAME wordpress SetEnv WP_DB_USER mysqluser SetEnv WP_DB_PASSWORD p@ssw0rd SetEnv WP_DB_HOST dbhostname
Step 2: call the variables in /var/www/html/wp-config.php:
/** The name of the database for WordPress */
define('DB_NAME', $_SERVER['WP_DB_NAME']);
/** MySQL database username */
define('DB_USER', $_SERVER['WP_DB_USER']);
/** MySQL database password */
define('DB_PASSWORD', $_SERVER['WP_DB_PASSWORD']);
/** MySQL hostname */
define('DB_HOST', $_SERVER['WP_DB_HOST']);