好吧,直到最近,我的 Wordpress 博客还在我的 VPS 上完美运行。突然,我开始看到“建立数据库连接时出错”页面。
我在 wp-config.php 中检查了我的数据库用户和密码凭据,但一切似乎都很好。
我多次尝试 sudo service apache2 restart
和 sudo 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}
我搜索前往 this question 的路.不,我没有将我的服务器从 Ubuntu 12.04 更新到 14.04,它从一开始就在 Ubuntu 14.04 上运行。所以我决定试一试其中一个答案:
source /etc/apache2/envvars
/usr/apache2/sbin -V
sudo service apache2 restart
不再有“建立数据库连接时出错”页面!它又开始工作了!
除了,它没有,错误页面在一段时间后返回。从那以后,每次我的博客宕机时,我都通过上述三个命令手动重置缺少的环境变量。
每次我运行这些命令时,我的博客都会暂时运行,但一段时间后会返回“建立数据库连接时出错”页面。
这里有人可以帮我吗?
提前致谢!
编辑: Here是我的 wp-config.php 供引用。
最佳答案
检查你的配置文件,你可能会发现类似于下面提到的代码。
如果你发现了什么,然后从 config.php
文件中删除该行
define('WP_CACHE', true);
这可能是由于在某个时候添加了一个插件,并且如果该插件使用了类似的代码。因此,我建议您非常仔细地检查您的配置文件。
关于php - Wordpress:建立数据库连接时出错和 Apache2 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32796791/