建立数据库连接错误和Apache2问题


Wordpress: Error establishing database connection and Apache2 problems

好吧,直到最近,我的Wordpress博客在我的VPS上运行得很好。突然,我开始看到"建立数据库连接错误"页面。

我在wp-config.php中检查了我的数据库用户和密码凭证,但一切似乎都很好。

我多次尝试sudo service apache2 restartsudo service apache2 reload,但也没有真正工作。

所以,我试着运行apache2,我得到这个:

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}
我寻找解决这个问题的方法。不,我没有把我的服务器从Ubuntu 12.04更新到14.04,它从一开始就运行在Ubuntu 14.04上。所以我决定给其中一个答案一个机会:
source /etc/apache2/envvars
/usr/apache2/sbin -V
sudo service apache2 restart

不再有"建立数据库连接错误"页面!它又开始工作了!

但是,它没有,过了一会儿错误页面又回来了。从那时起,每当我的博客出现故障时,我都会通过上述三个命令手动重置丢失的环境。

每次我运行命令,我的博客暂时工作,但一段时间后又回到"建立数据库连接错误"页面。

这里有人能帮我一下吗?

提前谢谢你!

编辑:这是我的wp-config.php参考

检查您的配置文件,您可能会发现类似于下面提到的代码。

如果你发现了什么,然后从config.php文件中删除行

define('WP_CACHE', true);

这可能是由于在某个时候添加了一个插件,如果插件使用了类似的代码。所以,我建议你仔细检查你的config文件