Okay, so till recently, my WordPress blog was running perfectly on my VPS. Suddenly, I started seeing the ‘Error establishing database connection’ page.
I checked my database user and password credentials in wp-config.php, but everything seemed fine.
I tried sudo service apache2 restart
and sudo service apache2 reload
multiple times, but that didn’t really work either.
So, I try running apache2
and I got this:
radhika@algosaur:~$ apache2
[Sat Sep 26 07:23:42.098529 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Sat Sep 26 07:23:42.103296 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Sat Sep 26 07:23:42.103510 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Sat Sep 26 07:23:42.103706 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Sat Sep 26 07:23:42.103940 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Sep 26 07:23:42.173950 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Sep 26 07:23:42.175114 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Sat Sep 26 07:23:42.176655 2015] [core:warn] [pid 4151] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 2 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
I search my way to this question. No, I haven’t updated my server from Ubuntu 12.04 to 14.04, it was running on Ubuntu 14.04 from the very beginning. So I decide to give one of the answers a shot:
source /etc/apache2/envvars
/usr/apache2/sbin -V
sudo service apache2 restart
No ‘Error establishing database connection’ page anymore! It started working again!
Except, it didn’t and the error page came back after a while. Since then I’ve been manually resetting the envvars that are missing through the above three commands every time my blog goes down.
Every time I run the commands, my blog works temporarily, but goes back to the ‘Error establishing database connection’ page after some time.
Could someone here help me out?
Thank you so much in advance!
Edit: Here is my wp-config.php for reference.
Check your config file, you may find something similar to the below mentioned code.
If you find something then remove the line from
config.php
fileThis may occur due to adding a plugin at some time and if the plugin uses a similar code. So, I would suggest you to please check your config file very carefully.