简体   繁体   中英

Corrupted php.ini (wordpress)

I have been working on a Wordpress site that hasn't had any updates in many years and preparing it for a theme change as well.

After updating all plugins/Wordpress 5.2/PHP 7.2 everything seemed to be going well however the site has been experiencing intermittent crashing (it will work for awhile then it will crash for 5-10 minutes) [edit: The site crashing was probably not directly caused by the php.ini issue in retrospect]

Looking at the cpanel in the error logs I get the error:

PHP:  syntax error, unexpected TC_LABEL, expecting '=' in /home/website/public_html/php.ini on line 1 //sometimes it includes a referer

Running php -i | grep php.ini php -i | grep php.ini :

Configuration File (php.ini) Path => /opt/imh/imh-php72/root/usr/lib/php
Loaded Configuration File => /opt/imh/imh-php72/root/usr/lib/php/php.ini

The php.ini (in public_html ) contains the same repeated path many times (78,886 times according to my find and replace):

/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718

Line 1:

/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718[/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718P/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718H/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718P/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718]/opt/imh/imh-php72/root/usr/lib/php/extensions/no-debug-non-zts-20170718

I noticed that there was sometimes an extra character after 20170718 . I downloaded a local copy and did a find and replace and removed all instances of the path and what was left is a 'normal' php.ini (ie it's as if every character in the file was replaced with path + character )

[edit: Changing the public_html php.ini to php.ini_bk removes the error from cpanel logs]

Personal PS: Please note I am not a PHP nor Wordpress developer (typically I work in the MERN stack)

public_html is not the right place for php.ini

Can you do a

php -i | grep php.ini

You have several options... make a backup of your "old" php.ini first

  • rebuild your PHP configuration

  • download latest PHP

  • Download PHP source and just copy php.ini template out of that

Sometimes it is better to do a clean install & import than updating a very old WordPress.

Regards Tom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM