I was asked by my hosting provider to upgrade my PHP version as there was a recent DDoS attack and my site was impacted. They suggested that EasyApache 3 with PHP 5.6 is bad and I should consider upgrading to PHP 7.1 and EasyApache 4. I checked online and made the decision to move ahead with it, but then comes the issues. Let me share my thoughts.
I asked my hosting provider to upgrade the PHP and EasyApache and they did it. Guess what, my WordPress was not working immediately.
Common Issues with PHP 5.6 to 7.1 upgrade with WordPress
HTTP ERROR 500 : This is the first error I got ( below . I was confused on what to do, first the guy tells everything is good on server, your issue. I was like what ? He said it is your config issue and said he will revert back to 5.6 version. The site was back up but with old version. I did not give up, I said I want the upgrade.
whatareview.com is currently unable to handle this request.
HTTP ERROR 500
Solution : Initially, there were lot of false alarms like it was a plugin issue. I disabled JetPack , WP Total Cache, and other plugins as those were the errors. But, still did not go away. It turned out that the my PHP installation was missing the MySQL extension which is required by WordPress. You will get error like
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Basically, if you do the command
php -m | grep mysql,
you should get three items like below. If you do not get it, then you are missing those modules. You will need install them.
mysqli mysqlnd pdo_mysql
You can update with mySQL extensions using the command
apt-get update apt-get install php-mysql
You restart the required service and it should work fine.
Memory Limit Exhausted PHP Fatal error : You may encounter this error as well. You may even get email alerts.
[24-Dec-2017 12:46:19 UTC] PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 524288 bytes) in /home/xxx/public_html/wp-includes/SimplePie/Item.php on line 2815
[24-Dec-2017 12:46:20 UTC] PHP Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 32768 bytes) in /home/xxx/public_html/wp-includes/SimplePie/Item.php on line 2552
Solution : You should increase the memory limit to 128 MB for PHP 7.1 You do it like below.
I increased your memory_limit to 128MB on PHP 7.1. You need to Edit php.ini .Search “memory_limit” in your php.ini and change it to 128 MB.
You can check it by running the below command
php -i | grep memory
memory_limit => 128M => 128M
Email Alerts out of memory: You may also keep getting emails that is out of memory at times. Those alerts are just because PHP will be exceeding your virtual memory limit in the firewall.
Solution : The alerts are likely to go away since PHP 7 can execute PHP code faster. You can increase your Virtual Memory Size to 600 MB just in case. If you check using the below command, it should be like below.
grep PT_USERMEM /etc/csf/csf.conf PT_USERMEM = "600"
CURL Module Missing : WordPress was setup and working fine, but I was using Question2Answer software on other site, so I was getting erros when I was trying to post anything. Same HTTP Error 500 and no reason.
[25-Dec-2017 11:01:41 UTC] PHP Fatal error: Uncaught Error: Call to undefined function curl_init() in /home/xx/public_html/qa/qa-plugin/akismet-spam-filter/akismet.class.php:74 Stack trace:
Solution : You would very likely be missing CURL Module and need to enable the same to get it fixed. Below are the steps.
- Install CURL by typing
sudo apt-get install curl
- Restart Apache by typing
sudo service apache2 restart
- Install PHP5 CURL by typing
sudo apt-get install php5-curl
You will get prompt to install… say yes. - Restart Apache by typing
sudo service apache2 restart
- You are done and it should work !
I spend almost two days on and off to get this fixed. What has been your experience ? Share your experience and issues.