How do I make sure I'm using the latest version of PHP on Centos 7?
I want my website to be as performant and secure as possible with the latest version of PHP. For the server my WordPress site is hosted on, I want to ensure that is the case. If I am not already on the latest version of PHP, please let me know what steps I need to take to update.
First you can check your current version of PHP by running:
If you are already on 7.2 you're good to go! If not you can update with a couple steps
- Download the appropriate packages to your Linode:
wget -q http://rpms.remirepo.net/enterprise/remi-release-7.rpm wget -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
- Install and enable the packages:
rpm -i remi-release-7.rpm epel-release-latest-7.noarch.rpm yum-config-manager --enable remi-php72
- Lastly, install and update your system:
yum install php yum update
You can then confirm once again your version of PHP with:
Once that is done you may also need to update your Nginx or Apache servers to use the new version of PHP. This Community Site posts gives a great overview of how to do that.
Did all of the above, and my linode is still showing that I'm running php 5.4.16?
It looks like I missed on step. Right after enabling the packages you'll need to run:
yum install php
You should be able to run this now on your system and then check your php version once again to confirm the change has gone through.
I'll update the original post with this instruction as well.
I did the following (after having done the two wget lines):
sudo rpm -i remi-release-7.rpm epel-release-latest-7.noarch.rpm
warning: remi-release-7.rpm: Header V4 DSA/SHA1 Signature, key ID 00f97f56: NOKEY
package epel-release-7-11.noarch is already installed
I assume "warning" and then "… is already installed" means I can, at least for updating PHP, ignore the warning. So I continued:
sudo yum-config-manager --enable remi-php72
[sudo] password for ken:
sudo: yum-config-manager: command not found
Command not found?? Hmmm. I proceeded anyway, and as one would expect, I did not get updated to PHP 7.2. Note two things here:
(1) php --version
PHP: syntax error, unexpected '&' in /etc/php.ini on line 107
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
I fixed the /etc/php.ini file. The problem was a missing "E" in the word "Notice" in line 107, showing it here corrected as copied from the VIM listing:
Development Value: E_ALL & ~E_NOTICE & ~E_STRICT
(2) Still running PHP 5.4.
Bump. I am having the same problem as k4c4gorman. Except I haven't gotten past when I enter:
yum-config-manager --enable remi-php72
I get this response:
-bash yum-config-manager: command not found
Any answer? I am quite new to using linux and such.
I tried this site's way of updating PHP - it seemed to work, I think.
But it is quite different than what is suggested here. Should I be concerned?