我的虚拟专用服务器有问题。VPS 托管 2 个 wordpress 网站。从上周开始,服务器有时突然开始产生错误,两个网站都在前端显示以下错误。重新启动 Apache 网络服务器后 1 或 2 天就可以了,但这个时间似乎正在减少。
前端产生的错误是:
"Warning: Invalid argument supplied for foreach() in /var/www/html/domainname/wp-includes/locale.php on line 117 Warning: Invalid argument supplied for foreach() in /var/www/html/domainname/wp-includes/locale.php on line 159
Error establishing a database connection"
Locale.php 的内容:(对此没有任何更改)
function init() {
// The Weekdays
$this->weekday[0] = /* translators: weekday */ __('Sunday');
$this->weekday[1] = /* translators: weekday */ __('Monday');
$this->weekday[2] = /* translators: weekday */ __('Tuesday');
$this->weekday[3] = /* translators: weekday */ __('Wednesday');
$this->weekday[4] = /* translators: weekday */ __('Thursday');
$this->weekday[5] = /* translators: weekday */ __('Friday');
$this->weekday[6] = /* translators: weekday */ __('Saturday');
// The first letter of each day. The _%day%_initial suffix is a hack to make
// sure the day initials are unique.
$this->weekday_initial[__('Sunday')] = /* translators: one-letter abbreviation of the weekday */ __('S_Sunday_initial');
$this->weekday_initial[__('Monday')] = /* translators: one-letter abbreviation of the weekday */ __('M_Monday_initial');
$this->weekday_initial[__('Tuesday')] = /* translators: one-letter abbreviation of the weekday */ __('T_Tuesday_initial');
$this->weekday_initial[__('Wednesday')] = /* translators: one-letter abbreviation of the weekday */ __('W_Wednesday_initial');
$this->weekday_initial[__('Thursday')] = /* translators: one-letter abbreviation of the weekday */ __('T_Thursday_initial');
$this->weekday_initial[__('Friday')] = /* translators: one-letter abbreviation of the weekday */ __('F_Friday_initial');
$this->weekday_initial[__('Saturday')] = /* translators: one-letter abbreviation of the weekday */ __('S_Saturday_initial');
foreach ($this->weekday_initial as $weekday_ => $weekday_initial_) {
$this->weekday_initial[$weekday_] = preg_replace('/_.+_initial$/', '', $weekday_initial_);
}
// Abbreviations for each day.
$this->weekday_abbrev[__('Sunday')] = /* translators: three-letter abbreviation of the weekday */ __('Sun');
$this->weekday_abbrev[__('Monday')] = /* translators: three-letter abbreviation of the weekday */ __('Mon');
$this->weekday_abbrev[__('Tuesday')] = /* translators: three-letter abbreviation of the weekday */ __('Tue');
$this->weekday_abbrev[__('Wednesday')] = /* translators: three-letter abbreviation of the weekday */ __('Wed');
$this->weekday_abbrev[__('Thursday')] = /* translators: three-letter abbreviation of the weekday */ __('Thu');
$this->weekday_abbrev[__('Friday')] = /* translators: three-letter abbreviation of the weekday */ __('Fri');
$this->weekday_abbrev[__('Saturday')] = /* translators: three-letter abbreviation of the weekday */ __('Sat');
// The Months
$this->month['01'] = /* translators: month name */ __('January');
$this->month['02'] = /* translators: month name */ __('February');
$this->month['03'] = /* translators: month name */ __('March');
$this->month['04'] = /* translators: month name */ __('April');
$this->month['05'] = /* translators: month name */ __('May');
$this->month['06'] = /* translators: month name */ __('June');
$this->month['07'] = /* translators: month name */ __('July');
$this->month['08'] = /* translators: month name */ __('August');
$this->month['09'] = /* translators: month name */ __('September');
$this->month['10'] = /* translators: month name */ __('October');
$this->month['11'] = /* translators: month name */ __('November');
$this->month['12'] = /* translators: month name */ __('December');
// Abbreviations for each month. Uses the same hack as above to get around the
// 'May' duplication.
$this->month_abbrev[__('January')] = /* translators: three-letter abbreviation of the month */ __('Jan_January_abbreviation');
$this->month_abbrev[__('February')] = /* translators: three-letter abbreviation of the month */ __('Feb_February_abbreviation');
$this->month_abbrev[__('March')] = /* translators: three-letter abbreviation of the month */ __('Mar_March_abbreviation');
$this->month_abbrev[__('April')] = /* translators: three-letter abbreviation of the month */ __('Apr_April_abbreviation');
$this->month_abbrev[__('May')] = /* translators: three-letter abbreviation of the month */ __('May_May_abbreviation');
$this->month_abbrev[__('June')] = /* translators: three-letter abbreviation of the month */ __('Jun_June_abbreviation');
$this->month_abbrev[__('July')] = /* translators: three-letter abbreviation of the month */ __('Jul_July_abbreviation');
$this->month_abbrev[__('August')] = /* translators: three-letter abbreviation of the month */ __('Aug_August_abbreviation');
$this->month_abbrev[__('September')] = /* translators: three-letter abbreviation of the month */ __('Sep_September_abbreviation');
$this->month_abbrev[__('October')] = /* translators: three-letter abbreviation of the month */ __('Oct_October_abbreviation');
$this->month_abbrev[__('November')] = /* translators: three-letter abbreviation of the month */ __('Nov_November_abbreviation');
$this->month_abbrev[__('December')] = /* translators: three-letter abbreviation of the month */ __('Dec_December_abbreviation');
foreach ($this->month_abbrev as $month_ => $month_abbrev_) {
$this->month_abbrev[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_);
}
我没有更改 php 或 mysql 配置中的任何内容,我不知道为什么它开始出现这样的行为。
一个临时的解决方案是重新启动 httpd 服务,然后一切都会好起来大约 1 天,但似乎这个时间减少到有时半小时。
起初我认为这个问题是由 Mysql 引起的。但是,我配置了一个测试工具来测试mysql。在 VPS 遇到问题的时候,通过 Mysql 测试工具登录数据库没有问题。
老实说,我不是 php 大师,希望有人能让我走上正轨。我已经自己排查问题和浏览论坛几个小时了,但我现在不知道如何解决它。
如果您需要更多信息,请询问。提前谢谢了。
最好的问候,罗伯特