Here are approximate directions on how to update your PHP on your VPS server.
Please note that these instructions may change based on the version and type of server you have:
1. Login to your server via SSH.
1. First, you may want to check the current version of PHP. You can use this command to do it:
`php -v`1. Now, you need to add the necessary repositories. If you are using Ubuntu you can use the following commands:
`sudo apt-get install software-properties-common python-software-properties` `sudo add-apt-repository ppa:ondrej/php` And, if you are using CentOS, you can do it like this: `yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm` `yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm`1. Update the package lists for upgrades for packages that need upgrading, as well as for new packages that have just been added into the repositories:
`sudo apt-get update` Or, if you’re using CentOS, use this command: `yum update`1. Then, you can install PHP using the following commands:
- For Ubuntu:
`sudo apt-get install -y php7.4` If you need any extensions you can install them like so: `sudo apt-get install -y php7.4-xml php7.4-cgi php7.4-cli php7.4-apcu php7.4-mbstring php7.4-curl php7.4-zip php7.4-gd php7.4-mysql php7.4-soap`- For CentOS:
`yum install php74 php74-php-fpm php74-php-gd php74-php-json php74-php-mbstring php74-php-mysqlnd php74-php-xml php74-php-xmlrpc php74-php-curl`1. Once all installations are done, you can verify the upgrade by typing the following command:
`php -v`This command should display the newer PHP version that you’ve just installed.
Remember to always backup your data before starting any major system adjustments. Also note that, depending on the server setup and application requirement, some additional configurations might be necessary after the upgrade.
It’s recommended to have a System Administrator or someone with solid server management knowledge do it, especially on live/production systems.